e.g.1 Given input -> "I have 36 books, 40 pens2."; output -> "I evah 36 skoob, 40 2snep."
e.g.2 Compress the string "aabcccccaaa" to "a2b1c5a3"
e.g.3 Leetcode: Longest Substring Without Repeating Characters.
e.g.4 Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). (Leetcode: Minimum Window Substring)
从简单到难这些题目,但一定是用begin和end两个pointer这大家都知道,但有的题目是分段之间独立的,有些是overlap的也就是sliding window,但都可以用一种写法就是 while end < length 然后每次循环不换段的话end前进,换段的话begin前进,但保证begin和end都不会倒退那么时间复杂度一定是O(n) 这些套路无论简单还是难题都是一样的。而且固定一种自己最适应最理解的写法,就不变了,别一会这样一会那样写