当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- How long does it take you to work out an object-oriented programming interview question from Ali school?
- Working principle of gradient descent algorithm in machine learning
- Did you blog today?
- Python crawler actual combat details: crawling home of pictures
- It's so embarrassing, fans broke ten thousand, used for a year!
- How to select the evaluation index of classification model
- Vue 3 responsive Foundation
- Cos start source code and creator
- 速看!互联网、电商离线大数据分析最佳实践!(附网盘链接)
- Top 10 best big data analysis tools in 2020
猜你喜欢
随机推荐
Programmer introspection checklist
采购供应商系统是什么?采购供应商管理平台解决方案
Serilog原始碼解析——使用方法
50 + open source projects are officially assembled, and millions of developers are voting
2018中国云厂商TOP5:阿里云、腾讯云、AWS、电信、联通 ...
How long does it take you to work out an object-oriented programming interview question from Ali school?
Swagger 3.0 天天刷屏,真的香嗎?
WeihanLi.Npoi 1.11.0/1.12.0 Release Notes
xmppmini 專案詳解:一步一步從原理跟我學實用 xmpp 技術開發 4.字串解碼祕笈與訊息包
你的财务报告该换个高级的套路了——财务分析驾驶舱
Real time data synchronization scheme based on Flink SQL CDC
A debate on whether flv should support hevc
Let the front-end siege division develop independently from the back-end: Mock.js
如何玩转sortablejs-vuedraggable实现表单嵌套拖拽功能
Can't be asked again! Reentrantlock source code, drawing a look together!
Nodejs crawler captures ancient books and records, a total of 16000 pages, experience summary and project sharing
100元扫货阿里云是怎样的体验?
幽默:黑客式编程其实类似机器学习!
How do the general bottom buried points do?
多机器人行情共享解决方案