当前位置:网站首页>Summary of common string algorithms
Summary of common string algorithms
2020-11-06 01:18:00 【Clamhub's blog】
1、 Longest substring without repeating characters
3. Longest substring without repeating characters
Slide the window to solve the problem . Set up a map To store characters and where they appear , Redefine the start and end pointer of the window .
1 |
public static int lengthOfLongestSubstring(String s) { |
2、 Longest common subsequence
1143. Longest common subsequence
It involves the problem of finding subsequences of two strings , Generally, it is the category of dynamic programming . The difficulty is to find the state transition equation .
Define a two-dimensional array dp The length used to store the longest common subsequence , among dp[i][j] Express S1 Before i Characters and S2 Before j The length of the longest common subsequence of characters . consider S1i And S2j Whether the values are equal , It can be divided into the following two situations :
Refer to this !!
1 |
public static int longestCommonSubsequence(String text1, String text2) { |
3、 Longest repeating subarray
718. Longest repeating subarray
Dynamic programming problem :
1 |
public static int findLength(int[] A, int[] B) { |
4、 String inversion
Using two Pointers .
1 |
public static void reverseString(char[] s) { |
5、 Can a string consist of words in a dictionary
Given a string s And a dictionary dict, Determine whether a string can be composed of strings in a dictionary , A string in a dictionary can appear more than once . for example s=“Ilovebytedance”,dict={“I”,“love”,“bytedance”}
With dynamic programming ,dp[i] Representation string s[0~i] Whether it is separable bool value .
Bytes to beat Word splicing
139. Word splitting
Reference resources here !!!
It's also a dynamic programming problem :
1 |
public static boolean wordBreak(String s, List<String> wordDict) { |
6、 A full permutation of a given string
Algorithm problem solution : Given a string, output all strings in its full permutation form (JAVA Code )
The full permutation of strings Java Realization
The idea of recursion and backtracking .
summary
Most of the common string algorithms are dynamic programming problems .
版权声明
本文为[Clamhub's blog]所创,转载请带上原文链接,感谢
边栏推荐
- 遞迴思想的巧妙理解
- Listening to silent words: hand in hand teaching you sign language recognition with modelarts
- 钻石标准--Diamond Standard
- Group count - word length
- 数据产品不就是报表吗?大错特错!这分类里有大学问
- 向北京集结!OpenI/O 2020启智开发者大会进入倒计时
- PN8162 20W PD快充芯片,PD快充充电器方案
- 嘗試從零開始構建我的商城 (二) :使用JWT保護我們的資訊保安,完善Swagger配置
- 网络安全工程师演示:原来***是这样获取你的计算机管理员权限的!【维持】
- After brushing leetcode's linked list topic, I found a secret!
猜你喜欢
Aprelu: cross border application, adaptive relu | IEEE tie 2020 for machine fault detection
使用 Iceberg on Kubernetes 打造新一代云原生数据湖
Face to face Manual Chapter 16: explanation and implementation of fair lock of code peasant association lock and reentrantlock
关于Kubernetes 与 OAM 构建统一、标准化的应用管理平台知识!(附网盘链接)
DRF JWT authentication module and self customization
How to select the evaluation index of classification model
Computer TCP / IP interview 10 even asked, how many can you withstand?
你的财务报告该换个高级的套路了——财务分析驾驶舱
Character string and memory operation function in C language
直播预告 | 微服务架构学习系列直播第三期
随机推荐
Calculation script for time series data
High availability cluster deployment of jumpserver: (6) deployment of SSH agent module Koko and implementation of system service management
hadoop 命令总结
Working principle of gradient descent algorithm in machine learning
Can't be asked again! Reentrantlock source code, drawing a look together!
小程序入门到精通(二):了解小程序开发4个重要文件
Why do private enterprises do party building? ——Special subject study of geek state holding Party branch
Just now, I popularized two unique skills of login to Xuemei
OPTIMIZER_ Trace details
Listening to silent words: hand in hand teaching you sign language recognition with modelarts
Did you blog today?
Want to do read-write separation, give you some small experience
Let the front-end siege division develop independently from the back-end: Mock.js
PLC模拟量输入和数字量输入是什么
The practice of the architecture of Internet public opinion system
Python3 e-learning case 4: writing web proxy
事半功倍:在没有机柜的情况下实现自动化
H5 makes its own video player (JS Part 2)
数字城市响应相关国家政策大力发展数字孪生平台的建设
WeihanLi.Npoi 1.11.0/1.12.0 Release Notes