Array Techniques Flashcards
Technique 1
Sliding window
the two pointers usually move in the same direction will never overtake
Technique 2
Two pointers
two pointers is a more general version of sliding window where the point
Technique 4
Sorting the array
s the array sorted or partially sorted? If it is, some form of binary se
**Sometimes sorting the array first may significantly simplify the problem. Obviously this would not work if the order of array elements need to be preserved. **
Technique 3
Traversing from the right
Sometimes you can traverse the array starting from the right instead of
Technique 5
Precomputation
For questions where summation or multiplication of a subarray is involve
Technique 6
Index as a hash key
If you are given a sequence and the interviewer asks for O(1) space, it
Technique 7
Traversing the array more than once
This might be obvious, but traversing the array twice/thrice (as long as