Advertisement
Guest User

AlgoRecoDecember

a guest
Dec 9th, 2019
511
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. Algos-to-know (and also a list of algos to not bother learning!)
  3. for frontend software eng roles
  4. -Christian Padilla
  5.  
  6. -----------
  7. Core algos to memorize and practice frequently (implement on a whiteboard while talking):
  8.     -binary search of a sorted array (iterative and recursive)
  9.     -insertion sort
  10.     -merge sort
  11.     -inorder/preorder/postorder traversal of binary tree
  12.     -layer traversal of binary tree
  13.    
  14. Stretch goals if you have time to learn/practice:
  15.     -bucketsort (when and why to use it? stretch: how is it related to counting and radix sort?)
  16.     -quicksort (not more difficult to implement than merge sort, but more difficult conceptually. Once it clicks it is much easier)
  17. Super stretch:
  18.     -heapsort (heaps should absolutely be learned (see below), but heapsort itself isn't very important)
  19.     -quickselect
  20. -----
  21. Data structures worth implementing frequently:
  22.     -binary search tree
  23.     (good practice problem: https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/)
  24.     -min/max heap
  25.     (figuring out why heaps are badass and when to use them takes a while,
  26.     I recommend thinking hard about these questions:
  27.         https://www.geeksforgeeks.org/nearly-sorted-algorithm/
  28.         https://leetcode.com/problems/the-skyline-problem/
  29.         (the skyline problem is hard, check out Tushar's video for an intuition for how a heap speeds things up)
  30.     reasonably good video and article for learning what heaps are and how to implement them in JS:
  31.         https://www.youtube.com/watch?v=dM_JHpfFITs
  32.         https://codeburst.io/implementing-a-complete-binary-heap-in-javascript-the-priority-queue-7d85bd256ecf)
  33.     -queue
  34.     (don't actually need to bother implementing this as a linked list,
  35.     just be comfortable explaining why you might use a linked list rather than an array
  36.     (dequeueing from an array costs O(n) time because all other elements need to be reindexed,
  37.     whereas dequeuing from a linked list is O(1) because there are only a constant number of reassignments,
  38.     regardless of the size of the queue))
  39.     (bonus: mention that it still might be faster to implement as an array rather than LL thanks to "CPU cache locality".
  40.     Look that up if you're curious, super cool stuff)
  41. Stretch:
  42.     -tries (prefix trees, fun data structure, used for autocomplete)
  43.     -Bloom filter
  44.     -LRU cache (least-recently used eviction policy, rather than FIFO (queue) or LIFO (stack))
  45.     (if you can implement this as a Map() with associated doubly linked list (self-made)
  46.     you'll be totally fine for any data structure design questions)
  47.     (this is also just a very common interview question, so it's worth being aware of)
  48. -------
  49. Actual interview questions worth memorizing and practicing:
  50. Strings and arrays:
  51. -two sum:
  52.     https://leetcode.com/problems/two-sum/
  53. -isomorphic strings:
  54.     https://leetcode.com/problems/isomorphic-strings/
  55. -buy and sell stocks:
  56.     https://leetcode.com/problems/best-time-to-buy-and-sell-stock/
  57. -move zeroes right:
  58.     https://leetcode.com/problems/move-zeroes/
  59. -valid parentheses:
  60.     https://leetcode.com/problems/valid-parentheses/
  61. -merge intervals:
  62.     https://leetcode.com/problems/merge-intervals/
  63. -meeting rooms:
  64.     https://leetcode.com/problems/meeting-rooms/
  65. -Dutch national flag:
  66.     https://leetcode.com/problems/sort-colors
  67. -most common banned word:
  68.     https://leetcode.com/problems/most-common-word/
  69. -spiral matrix:
  70.     https://leetcode.com/problems/spiral-matrix/
  71. -range sum query (this is dynamic programming, a topic I recommend skipping (see below), but it comes up in other problems and so is probably worth knowing)
  72.     https://leetcode.com/problems/range-sum-query-immutable/
  73. -search in rotated sorted array (common question, tedious problem, same with "find median of two sorted arrays". Maybe just look at these):
  74.     https://leetcode.com/problems/search-in-rotated-sorted-array/
  75. Backtracking:
  76. -generate permutations:
  77.     https://leetcode.com/problems/permutations/
  78. -generate combinations:
  79.     https://leetcode.com/problems/combinations/
  80. -generate valid parentheses:
  81.     https://leetcode.com/problems/generate-parentheses/
  82. -combination sums:
  83.     https://leetcode.com/problems/combination-sum/
  84. Trees and recursion:
  85. -convert sorted array to binary search tree of minimum height:
  86.     https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/
  87. -determine if a given binary tree is balanced:
  88.     https://leetcode.com/problems/balanced-binary-tree/
  89. -lowest common ancestor of two nodes in a binary tree:
  90.     https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/
  91. -deep clone JS object
  92. -deep clone graph:
  93.     https://leetcode.com/problems/clone-graph/
  94. -deep clone linked list with "random" pointers:
  95.     https://leetcode.com/problems/copy-list-with-random-pointer/
  96. Sliding window:
  97. -longest substring without repeating characters
  98.     https://leetcode.com/problems/longest-substring-without-repeating-characters/
  99. -sliding window maximum
  100.     https://leetcode.com/problems/sliding-window-maximum/submissions/
  101. -longest substring with at most k distinct characters
  102. (this is a great problem for understanding how useful heaps are)
  103.     https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters/
  104.    
  105. graph stuff:
  106. -course schedule
  107.     https://leetcode.com/problems/course-schedule/
  108. 2D matrix stuff:
  109. (these types of problems are usually very similar and very common in my experience)
  110. -number of islands (a classic, I super recommend being confident with this one)
  111.     https://leetcode.com/problems/number-of-islands/
  112. -word search and word search 2 (ws2 is fancy, using a trie to speed up lookup)
  113.     https://leetcode.com/problems/word-search/
  114.     https://leetcode.com/problems/word-search-ii/
  115. -longest increasing path in matrix
  116.     https://leetcode.com/problems/longest-increasing-path-in-a-matrix/
  117. -------
  118. Things probably not worth studying (maybe more common for backend roles or new CS grads):
  119. -Linked list problems (just check out "reverse a linked list")
  120. -Bottom-up dynamic programming (aka tabulation)
  121.     (if you want to learn it anyways, do these problems in order:
  122.     -nth fibonacci number (https://leetcode.com/problems/fibonacci-number/)
  123.     -count stairs (https://leetcode.com/problems/climbing-stairs/)
  124.     -jump game (https://leetcode.com/articles/jump-game/)
  125.     -range sum query (https://leetcode.com/problems/range-sum-query-immutable/)
  126.     -coin change (https://leetcode.com/problems/coin-change/)
  127.     -coin sum (https://leetcode.com/problems/coin-change-2/)
  128.     -equal subset sums (https://leetcode.com/problems/partition-equal-subset-sum/)
  129.     -interleaving strings (https://leetcode.com/problems/interleaving-string/)
  130.     -edit distance (https://leetcode.com/problems/edit-distance/)
  131. -fancy graph algorithms (weighted graphs, pretty much):
  132.     -minimum spanning tree
  133.     -Bellman-Ford
  134.     -Dijkstra's
  135.     -A*
  136. -Self-balancing binary trees (definitely want to know why they are important, but do not need to be able to implement any of them):
  137.     -AVL trees
  138.     -red-black trees
  139. -Knuth-Morris-Pratt string matching (and other state machine stuff)
  140. --------
  141. Also, here are my favorite general algo-interviewing resources:
  142. https://jeremyaguilon.me/blog/visualizing_four_key_interview_algorithms
  143.     (learning the sliding window technique is super important and very valuable to feel confident,
  144.     see below for my list of sliding window problems)
  145. https://jeremyaguilon.me/blog/ranking_interview_questions_by_cram_score
  146.     (keep in mind that most of the algos in the cram list are overkill for frontend interviews, in my experience)
  147.     (still worth looking at some of the solutions/explanations)
  148. https://leetcode.com/explore/
  149.     (leetcode also has an "interview experience" page where people list questions they have gotten recently)
  150.     (https://leetcode.com/discuss/interview-experience/)
  151. https://app.codesignal.com/
  152.     (if you don't feel confident with leetcode problems, start by doing the intro arcade questions here)
  153.     (if you get at all stuck (or if it's a regex question), just spend coins (free) to look at the answer for these)
  154. https://github.com/gmal1/algoholics-anon
  155.     (repo of simple implementations of most of the stuff below)
  156. Tushar Roy - https://www.youtube.com/user/tusharroy2525/videos
  157.  
  158. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement