当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- Flink的DataSource三部曲之二:内置connector
- 网络安全工程师演示:原来***是这样获取你的计算机管理员权限的!【维持】
- 中小微企业选择共享办公室怎么样?
- 熬夜总结了报表自动化、数据可视化和挖掘的要点,和你想的不一样
- Just now, I popularized two unique skills of login to Xuemei
- Let the front-end siege division develop independently from the back-end: Mock.js
- 3分钟读懂Wi-Fi 6于Wi-Fi 5的优势
- Analysis of ThreadLocal principle
- PHP应用对接Justswap专用开发包【JustSwap.PHP】
- Filecoin主网上线以来Filecoin矿机扇区密封到底是什么意思
猜你喜欢

条码生成软件如何隐藏部分条码文字

Troubleshooting and summary of JVM Metaspace memory overflow

在大规模 Kubernetes 集群上实现高 SLO 的方法

Network security engineer Demo: the original * * is to get your computer administrator rights! 【***】

速看!互联网、电商离线大数据分析最佳实践!(附网盘链接)

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

Subordination judgment in structured data

华为云“四个可靠”的方法论

hadoop 命令总结

Elasticsearch database | elasticsearch-7.5.0 application construction
随机推荐
全球疫情加速互联网企业转型,区块链会是解药吗?
连肝三个通宵,JVM77道高频面试题详细分析,就这?
Serilog原始碼解析——使用方法
Save the file directly to Google drive and download it back ten times faster
網路程式設計NIO:BIO和NIO
OPTIMIZER_ Trace details
嘘!异步事件这样用真的好么?
多机器人行情共享解决方案
向北京集结!OpenI/O 2020启智开发者大会进入倒计时
Want to do read-write separation, give you some small experience
PN8162 20W PD快充芯片,PD快充充电器方案
Asp.Net Core學習筆記:入門篇
“颜值经济”的野望:华熙生物净利率六连降,收购案遭上交所问询
Query意图识别分析
Did you blog today?
Using consult to realize service discovery: instance ID customization
Programmer introspection checklist
從小公司進入大廠,我都做對了哪些事?
High availability cluster deployment of jumpserver: (6) deployment of SSH agent module Koko and implementation of system service management
深度揭祕垃圾回收底層,這次讓你徹底弄懂她