代码随想录算法训练营第9天内容2 |字符串总结
字符串总结
基础操作 —— 反转字符串
- 344 反转字符串:字符串变成列表才能可替代;不要随便用库函数
https://leetcode.cn/problems/reverse-string/description/ -
- 反转字符串 II:遍历的秘诀;
https://leetcode.cn/problems/reverse-string-ii/description/
- 反转字符串 II:遍历的秘诀;
- 151.翻转字符串里的单词:strip函数;转为list
https://leetcode.cn/problems/reverse-words-in-a-string/ - 右旋字符串:两次反转为正
https://kamacoder.com/problempage.php?pid=1065
字符串匹配 —— KMP next数组
- 匹配问题:28. 实现 strStr():如果不符合标准,就跳至前一个符合标准的位置继续
https://leetcode.cn/problems/find-the-index-of-the-first-occurrence-in-a-string/ - 重复子串问题:459.重复的子字符串:1.首尾相连还有本身; 2.最大公共前后缀 长度-最后一位最大相同前后缀的部分是否能被整除;https://leetcode.cn/problems/repeated-substring-pattern/
双指针总结
- 移除数组元素
- 字符串反转
- 替换空格;删除单词中的空格;
- 链表反转
- 链表找环;链表找入口
- 三数之和;四数之和
- 二分查找;