当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- 大数据应用的重要性体现在方方面面
- C++和C++程序员快要被市场淘汰了
- Use of vuepress
- 人工智能学什么课程?它将替代人类工作?
- It's so embarrassing, fans broke ten thousand, used for a year!
- Kitty中的动态线程池支持Nacos,Apollo多配置中心了
- 数字城市响应相关国家政策大力发展数字孪生平台的建设
- Let the front-end siege division develop independently from the back-end: Mock.js
- 在大规模 Kubernetes 集群上实现高 SLO 的方法
- 比特币一度突破14000美元,即将面临美国大选考验
猜你喜欢

直播预告 | 微服务架构学习系列直播第三期

加速「全民直播」洪流,如何攻克延时、卡顿、高并发难题?

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

做外包真的很难,身为外包的我也无奈叹息。

Do not understand UML class diagram? Take a look at this edition of rural love class diagram, a learn!

使用 Iceberg on Kubernetes 打造新一代云原生数据湖

Can't be asked again! Reentrantlock source code, drawing a look together!

阿里云Q2营收破纪录背后,云的打开方式正在重塑

Jmeter——ForEach Controller&Loop Controller

数据产品不就是报表吗?大错特错!这分类里有大学问
随机推荐
如何玩转sortablejs-vuedraggable实现表单嵌套拖拽功能
Flink的DataSource三部曲之二:内置connector
xmppmini 專案詳解:一步一步從原理跟我學實用 xmpp 技術開發 4.字串解碼祕笈與訊息包
DTU连接经常遇到的问题有哪些
【效能優化】納尼?記憶體又溢位了?!是時候總結一波了!!
PHP应用对接Justswap专用开发包【JustSwap.PHP】
2019年的一个小目标,成为csdn的博客专家,纪念一下
Skywalking series blog 5-apm-customize-enhance-plugin
After reading this article, I understand a lot of webpack scaffolding
连肝三个通宵,JVM77道高频面试题详细分析,就这?
Query意图识别分析
50 + open source projects are officially assembled, and millions of developers are voting
Group count - word length
ES6 essence:
Details of dapr implementing distributed stateful service
Filecoin最新动态 完成重大升级 已实现四大项目进展!
3分钟读懂Wi-Fi 6于Wi-Fi 5的优势
Nodejs crawler captures ancient books and records, a total of 16000 pages, experience summary and project sharing
Grouping operation aligned with specified datum
Serilog原始碼解析——使用方法