在 LeetCode 上做字符处理的题目时,一般我用两个 for 套在一起循环遍历,最后要么超时,要么时间太长了,一直没找到特别好的方法,请问在处理这一类问题时有什么特别好的解法吗?
比如下面的题目:
https://leetcode.com/problems/longest-substring-without-repeating-characters
https://leetcode.com/problems/longest-palindromic-substring/#/description
比如下面的题目:
https://leetcode.com/problems/longest-substring-without-repeating-characters
https://leetcode.com/problems/longest-palindromic-substring/#/description