当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- CCR炒币机器人:“比特币”数字货币的大佬,你不得不了解的知识
- Using Es5 to realize the class of ES6
- Programmer introspection checklist
- Jmeter——ForEach Controller&Loop Controller
- Character string and memory operation function in C language
- Chainlink将美国选举结果带入区块链 - Everipedia
- xmppmini 專案詳解:一步一步從原理跟我學實用 xmpp 技術開發 4.字串解碼祕笈與訊息包
- Installing the consult cluster
- WeihanLi.Npoi 1.11.0/1.12.0 Release Notes
- 网络安全工程师演示:原来***是这样获取你的计算机管理员权限的!【维持】
猜你喜欢

Use of vuepress

3分钟读懂Wi-Fi 6于Wi-Fi 5的优势

大数据应用的重要性体现在方方面面

Kitty中的动态线程池支持Nacos,Apollo多配置中心了

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

Just now, I popularized two unique skills of login to Xuemei

Troubleshooting and summary of JVM Metaspace memory overflow

人工智能学什么课程?它将替代人类工作?

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

熬夜总结了报表自动化、数据可视化和挖掘的要点,和你想的不一样
随机推荐
2019年的一个小目标,成为csdn的博客专家,纪念一下
How long does it take you to work out an object-oriented programming interview question from Ali school?
做外包真的很难,身为外包的我也无奈叹息。
如何将数据变成资产?吸引数据科学家
ES6 essence:
Flink on paasta: yelp's new stream processing platform running on kubernetes
High availability cluster deployment of jumpserver: (6) deployment of SSH agent module Koko and implementation of system service management
Elasticsearch 第六篇:聚合統計查詢
Character string and memory operation function in C language
采购供应商系统是什么?采购供应商管理平台解决方案
Subordination judgment in structured data
Polkadot series (2) -- detailed explanation of mixed consensus
After reading this article, I understand a lot of webpack scaffolding
容联完成1.25亿美元F轮融资
Network security engineer Demo: the original * * is to get your computer administrator rights! 【***】
事半功倍:在没有机柜的情况下实现自动化
Synchronous configuration from git to consult with git 2consul
[performance optimization] Nani? Memory overflow again?! It's time to sum up the wave!!
Listening to silent words: hand in hand teaching you sign language recognition with modelarts
Face to face Manual Chapter 16: explanation and implementation of fair lock of code peasant association lock and reentrantlock