Recently I spent few hours on going through algorithm questions in leetcode. I haven’t touched the algorithm question for 2 years but I think it’s a good time to review those questions in a better way.
From my experience, the thinking strategy of solving similar problems is limited. Those strategies cannot help you solve all problems relevant to Array but it may be a good beginning of analyzing those algorithm tricks.
The core is the math
- Hash Table
- shifting the array from beginning to the end or with odd & even order
- use *-1 as a mark
- two indexes, two-way or one-way moving, or 1 , n-1
- convert the index into other marks e.g. content vice versa
- if it’s matrix, sum the columns and rows
- switch i and i+1 bubble sort
- use mid number quicksort