当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- Python crawler actual combat details: crawling home of pictures
- Elasticsearch database | elasticsearch-7.5.0 application construction
- Examples of unconventional aggregation
- Process analysis of Python authentication mechanism based on JWT
- DRF JWT authentication module and self customization
- Serilog原始碼解析——使用方法
- Existence judgment in structured data
- Not long after graduation, he earned 20000 yuan from private work!
- OPTIMIZER_ Trace details
- CCR炒币机器人:“比特币”数字货币的大佬,你不得不了解的知识
猜你喜欢

Filecoin最新动态 完成重大升级 已实现四大项目进展!

数字城市响应相关国家政策大力发展数字孪生平台的建设

Not long after graduation, he earned 20000 yuan from private work!

怎么理解Python迭代器与生成器?

网络安全工程师演示:原来***是这样获取你的计算机管理员权限的!【维持】

Use of vuepress

全球疫情加速互联网企业转型,区块链会是解药吗?

小程序入门到精通(二):了解小程序开发4个重要文件

关于Kubernetes 与 OAM 构建统一、标准化的应用管理平台知识!(附网盘链接)

你的财务报告该换个高级的套路了——财务分析驾驶舱
随机推荐
2019年的一个小目标,成为csdn的博客专家,纪念一下
Do not understand UML class diagram? Take a look at this edition of rural love class diagram, a learn!
Skywalking series blog 1 - install stand-alone skywalking
Use of vuepress
PHP应用对接Justswap专用开发包【JustSwap.PHP】
C language 100 question set 004 - statistics of the number of people of all ages
3分钟读懂Wi-Fi 6于Wi-Fi 5的优势
如何玩转sortablejs-vuedraggable实现表单嵌套拖拽功能
熬夜总结了报表自动化、数据可视化和挖掘的要点,和你想的不一样
Why do private enterprises do party building? ——Special subject study of geek state holding Party branch
Existence judgment in structured data
How to demote a domain controller in Windows Server 2012 and later
How to get started with new HTML5 (2)
Python crawler actual combat details: crawling home of pictures
DevOps是什么
【效能優化】納尼?記憶體又溢位了?!是時候總結一波了!!
EOS创始人BM: UE,UBI,URI有什么区别?
华为云“四个可靠”的方法论
IPFS/Filecoin合法性:保护个人隐私不被泄露
关于Kubernetes 与 OAM 构建统一、标准化的应用管理平台知识!(附网盘链接)