Two Pointers of Tips:

  • Double pointer sliding window classical writing method. The right pointer moves to the right until it can no longer move to the right (depending on the problem). When the right pointer reaches the far right, start moving the left pointer to release the window left boundary. Problem 3. 76, 209, 438, 567, 713, 763, 845, 881, 904, 992, 1004.
	left, right := 0.- 1

	for left < len(s) {
		if right+1 < len(s) && freq[s[right+1] -'a'] = =0 {
			freq[s[right+1] -'a']++
			right++
		} else {
			freq[s[left]-'a']--
			left++
		}
		result = max(result, right-left+1)}Copy the code
  • Fast and slow Pointers can find repeated numbers. Time complexity O(n), problem 287.
  • After substituting letters, the longest consecutive length of the same letter can appear. The 424th.
  • SUM problem set. Problem 1, 15, 16, 18, 167, 923.
Title Solution Difficulty Time Space collection
3. Longest Substring Without Repeating Characters Go Medium O(n) O(1) ❤ ️
11. Container With Most Water Go Medium O(n) O(1)
15. 3Sum Go Medium O(n^2) O(n) ❤ ️
16. 3Sum Closest Go Medium O(n^2) O(1) ❤ ️
18. 4Sum Go Medium O(n^3) O(n^2) ❤ ️
19. Remove Nth Node From End of List Go Medium O(n) O(1)
26. Remove Duplicates from Sorted Array Go Easy O(n) O(1)
27. Remove Element Go Easy O(n) O(1)
28. Implement strStr() Go Easy O(n) O(1)
30. Substring with Concatenation of All Words Go Hard O(n) O(n) ❤ ️
42. Trapping Rain Water Go Hard O(n) O(1) ❤ ️
61. Rotate List Go Medium O(n) O(1)
75. Sort Colors Go Medium O(n) O(1) ❤ ️
76. Minimum Window Substring Go Hard O(n) O(n) ❤ ️
80. Remove Duplicates from Sorted Array II Go Medium O(n) O(1
86. Partition List Go Medium O(n) O(1) ❤ ️
88. Merge Sorted Array Go Easy O(n) O(1) ❤ ️
125. Valid Palindrome Go Easy O(n) O(1)
141. Linked List Cycle Go Easy O(n) O(1) ❤ ️
142. Linked List Cycle II Go Medium O(n) O(1) ❤ ️
167. Two Sum II – Input array is sorted Go Easy O(n) O(1)
209. Minimum Size Subarray Sum Go Medium O(n) O(1)
234. Palindrome Linked List Go Easy O(n) O(1)
283. Move Zeroes Go Easy O(n) O(1)
287. Find the Duplicate Number Go Easy O(n) O(1) ❤ ️
344. Reverse String Go Easy O(n) O(1)
345. Reverse Vowels of a String Go Easy O(n) O(1)
349. Intersection of Two Arrays Go Easy O(n) O(n)
350. Intersection of Two Arrays II Go Easy O(n) O(n)
424. Longest Repeating Character Replacement Go Medium O(n) O(1)
524. Longest Word in Dictionary through Deleting Go Medium O(n) O(1)
532. K-diff Pairs in an Array Go Easy O(n) O(n)
567. Permutation in String Go Medium O(n) O(1) ❤ ️
713. Subarray Product Less Than K Go Medium O(n) O(1)
763. Partition Labels Go Medium O(n) O(1) ❤ ️
826. Most Profit Assigning Work Go Medium O(n log n) O(n)
828. Unique Letter String Go Hard O(n) O(1) ❤ ️
838. Push Dominoes Go Medium O(n) O(n)
844. Backspace String Compare Go Easy O(n) O(n)
845. Longest Mountain in Array Go Medium O(n) O(1)
881. Boats to Save People Go Medium O(n log n) O(1)
904. Fruit Into Baskets Go Medium O(n log n) O(1)
923. 3Sum With Multiplicity Go Medium O(n^2) O(n)
925. Long Pressed Name Go Easy O(n) O(1)
930. Binary Subarrays With Sum Go Medium O(n) O(n) ❤ ️
977. Squares of a Sorted Array Go Easy O(n) O(1)
986. Interval List Intersections Go Medium O(n) O(1)
992. Subarrays with K Different Integers Go Hard O(n) O(n) ❤ ️
1004. Max Consecutive Ones III Go Medium O(n) O(1)
1093. Statistics from a Large Sample Go Medium O(n) O(1)