- Two Sum/
- Recurse twice --> O(n^2)
- Could use a Hash Map for better complexity--> O(n)
- Reverse Linked List/
- Spacial & Temporal Complexity
- Adding a Prev pointer to save "space": Spcial O(1) vs O(n)
- Valid Permutations for DI Sequence/
- Using python @lru_cache(None)
- using dynamic programming to avoid repeated work
- Merge Two Sorted Lists /
- Could implement using recursion
- Could also have O(1) complexity by using pointers
Similar practices
- Fibonacci Number
- Climbing Stairs
- Valid Parentheses
- Happy Number/
- Surface Area of 3D Shapes:
- Reading the question: be more patient and plug in variables
- parenthesis on pointers while incrementing , debugging by segments
- Using comments smartly
- Using auto keyword/ptrs, vector indexes, syntactic sugar in cpp.
- Problem of 3D shapes: use (sum - touching) rather than six sides(hidden surfaces)