当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- Did you blog today?
- 向北京集结!OpenI/O 2020启智开发者大会进入倒计时
- Every day we say we need to do performance optimization. What are we optimizing?
- High availability cluster deployment of jumpserver: (6) deployment of SSH agent module Koko and implementation of system service management
- Network programming NiO: Bio and NiO
- 容联完成1.25亿美元F轮融资
- H5 makes its own video player (JS Part 2)
- Chainlink将美国选举结果带入区块链 - Everipedia
- Polkadot series (2) -- detailed explanation of mixed consensus
- 连肝三个通宵,JVM77道高频面试题详细分析,就这?
猜你喜欢
做外包真的很难,身为外包的我也无奈叹息。
Not long after graduation, he earned 20000 yuan from private work!
条码生成软件如何隐藏部分条码文字
选择站群服务器的有哪些标准呢?
Use of vuepress
DRF JWT authentication module and self customization
Basic principle and application of iptables
Using Es5 to realize the class of ES6
事半功倍:在没有机柜的情况下实现自动化
Vue 3 responsive Foundation
随机推荐
有关PDF417条码码制的结构介绍
100元扫货阿里云是怎样的体验?
使用 Iceberg on Kubernetes 打造新一代云原生数据湖
Polkadot series (2) -- detailed explanation of mixed consensus
03_ Detailed explanation and test of installation and configuration of Ubuntu Samba
中国提出的AI方法影响越来越大,天大等从大量文献中挖掘AI发展规律
High availability cluster deployment of jumpserver: (6) deployment of SSH agent module Koko and implementation of system service management
How long does it take you to work out an object-oriented programming interview question from Ali school?
Vuejs development specification
Introduction to Google software testing
Use of vuepress
PHPSHE 短信插件说明
在大规模 Kubernetes 集群上实现高 SLO 的方法
Python + appium automatic operation wechat is enough
Sort the array in ascending order according to the frequency
事半功倍:在没有机柜的情况下实现自动化
速看!互联网、电商离线大数据分析最佳实践!(附网盘链接)
Let the front-end siege division develop independently from the back-end: Mock.js
Analysis of react high order components
Filecoin的经济模型与未来价值是如何支撑FIL币价格破千的