I am trying to document the solution from solving Leetcode frequently.
Let me know if you want me to try any problem !
Problem 28 : Find the Index of the First Occurrence in a String
Core thought : Brute force
Optimization thought (KMP algorithm):
Similar problem : Shortest Palindrome, Repeated Substring Pattern
Problem 58 : Length of Last Word
Core thought : Going this way <-
Similar problem : Basic Calculator, Goal Parser Interpretation Substrings That Begin and End With the Same Letter
Problem 1968 : Array With Elements Not Equal to Average of Neighbors
Core thought : Think about a zigzac
Similar problem : Wiggle Sort, Wiggle Sort II
Problem 167 : Two Sum II - Input Array Is Sorted
Core thought : left -> and right <- until target == nums[left]+nums[right]
Similar problem : Two Sum IV - Input is a BST, Two Sum Less Than K
Problem 881 : Boats to save people
Core thought : Sorting then squeeze (read code for better explanation)
Similar problem : Find the most Competitive Subsequence,
Find the maximum number of marked indices, Two City Scheduling
Problem 283 : Move Zeroes
Core thought : Imagine a snowball roll down the hill
Similar problem : Remove Element, Apply Operations to an Array
Problem 219 : Contain Duplicate II
Core thought : Hashmap, what happen when you encounter nums[i]==nums[j] (i < j)
Similar problem : Contain Duplicate III