davidoh

IPA - /ˈdeɪvɪd oʊ/

davidoh2018 [at] gmail [dot] com

  • If input array is sorted:
    • Binary Search
    • Two Pointers
  • If given a tree:
    • DFS
    • BFS
  • If asked for all permutations/subsets:
    • Backtracking
  • If given a graph:
    • DFS
    • BFS
  • If given a linked list:
    • Two Pointers
  • If Recursion is banned:
    • Stack
  • If asked for max/min subarray/subsets/options:
    • Dynamic Programming
  • If asked for top/least K ITEMS:
    • Heap
  • If asked for common strings:
    • Map
    • Trie
  • If need to keep count of distinct elements:
    • Map
    • Set
  • Else:
    • Map/Set for O(1) time & O(n) space
    • Sort input for O(nLogn) time and O(1) space
Back to main