i take one breath / mint at a time

Summary, 4 weeks in.

#devstudy #algorithmns #datastructures #problemsolving

Read Before Starting

STOP SKIPPING STEPS EVEN ON EASY QUESTIONS!!!!!!!!!! YOU WILL REGRET IT EVERYTIME!!!!!!!!!!!!!

Most Common Mistakes

EFFY PLEASE VISUALIZE/WRITE MORE TEST CASES
– misinterpreting the problem bc going too fast
– misunderstanding the problem bc going too fast
– implementation issues with scoping

If Stuck

  1. Can you reverse the interpretation?
  2. Can you start the approach with the another input and/or direction?
  3. Can you use a set or a map to store something you're manually reaching for at a later point?
  4. Can you break down the problem more?
  5. Did you make a table of cases to fully visualize the pattern or did you trust your assumptions? Don't trust your assumptions.

Interpretation Patterns

If input array is sorted then
– Binary search
– Two pointers

If asked for all permutations/subsets then
– Backtracking

If given a tree then
– DFS
– BFS

If given a graph then
– DFS
– BFS

If given a linked list then
– Two pointers

If recursion is banned then
– Stack

If must solve in-place then
– Swap corresponding values
– Store one or more different values in the same pointer

If asked for maximum/minimum subarray/subset/options then
– Dynamic programming

If asked for top/least K items then
– Heap

If asked for common strings then
– Map
– Tree

Else
– Map/Set for O(1) time & O(n) space
– Sort input for O(nlogn) time and O(1) space