Left and Right Pointers
Needs to be ordered
Three Sum
- Outer-layer deduplication (on
i): Skip repeated starting values so each distinct number is used only once as the first element. - Inner-layer deduplication (on
landr): After finding a triplet, skip repeated values at the left and right pointers so each triplet is produced only once.
Sliding Window
Check the condition between one window
Don’t need to be ordered
Longest Substring without Repetition
vector<int> last(256,-1)records the last position of a character, 255 characters maxlast[c] >= las c has to be within the [l,r]
Leave a Reply