Skip to content

Instantly share code, notes, and snippets.

@shipitsteven
Forked from tykurtz/grokking_to_leetcode.md
Last active September 20, 2023 00:07
Show Gist options
  • Select an option

  • Save shipitsteven/967a68211769739bce2120f25d51a14e to your computer and use it in GitHub Desktop.

Select an option

Save shipitsteven/967a68211769739bce2120f25d51a14e to your computer and use it in GitHub Desktop.
Grokking the coding interview equivalent leetcode problems

GROKKING NOTES

I liked the way Grokking the coding interview organized problems into learnable patterns. However, the course is expensive and the majority of the time the problems are copy-pasted from leetcode. As the explanations on leetcode are usually just as good, the course really boils down to being a glorified curated list of leetcode problems.

So below I made a list of leetcode problems that are as close to grokking problems as possible.

  1. Pattern: Sliding Window https://leetcode.com/problems/maximum-subarray/ # Close enough

https://leetcode.com/problems/minimum-size-subarray-sum/

https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters/

https://leetcode.com/problems/fruit-into-baskets/

https://leetcode.com/problems/longest-substring-without-repeating-characters/

https://leetcode.com/problems/longest-repeating-character-replacement/

https://leetcode.com/problems/max-consecutive-ones-iii/

https://leetcode.com/problems/permutation-in-string/

https://leetcode.com/problems/find-all-anagrams-in-a-string/

https://leetcode.com/problems/minimum-window-substring/

https://leetcode.com/problems/substring-with-concatenation-of-all-words/

  1. Pattern: Two Pointers https://leetcode.com/problems/two-sum/

https://leetcode.com/problems/remove-duplicates-from-sorted-array/

https://leetcode.com/problems/squares-of-a-sorted-array/

https://leetcode.com/problems/3sum/

https://leetcode.com/problems/3sum-closest/

https://leetcode.com/problems/3sum-smaller/

https://leetcode.com/problems/subarray-product-less-than-k/

https://leetcode.com/problems/sort-colors/

https://leetcode.com/problems/4sum/

https://leetcode.com/problems/backspace-string-compare/

https://leetcode.com/problems/shortest-unsorted-continuous-subarray/

  1. Pattern: Fast & Slow pointers https://leetcode.com/problems/linked-list-cycle/

https://leetcode.com/problems/linked-list-cycle-ii/

https://leetcode.com/problems/happy-number/

https://leetcode.com/problems/middle-of-the-linked-list/

https://leetcode.com/problems/palindrome-linked-list/

https://leetcode.com/problems/reorder-list/

https://leetcode.com/problems/circular-array-loop/

  1. Pattern: Merge Intervals https://leetcode.com/problems/merge-intervals/

https://leetcode.com/problems/insert-interval/

https://leetcode.com/problems/interval-list-intersections/

https://leetcode.com/problems/meeting-rooms-ii/

Could not find equivalent. Given a list of intervals with values, find the peak sum (i.e. if intervals are overlapping, sum their values)

https://leetcode.com/problems/employee-free-time/

  1. Pattern: Cyclic Sort

Couldn't find equivalent for the first question. The second question below encompasses the first one though.

grokking the coding interview approached these problems.

It uses the fact that we can sort the array in O(n) without comparison operators

https://leetcode.com/problems/missing-number/

https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/

https://leetcode.com/problems/find-all-duplicates-in-an-array/

combine https://leetcode.com/problems/find-the-duplicate-number/ and https://leetcode.com/problems/missing-number/

https://leetcode.com/problems/first-missing-positive/

https://leetcode.com/problems/kth-missing-positive-number/

  1. Pattern: In-place Reversal of a LinkedList

https://leetcode.com/problems/reverse-linked-list/

https://leetcode.com/problems/reverse-linked-list-ii/

https://leetcode.com/problems/reverse-nodes-in-k-group/

Next question is the same, but alternate each subgroup

https://leetcode.com/problems/rotate-list/

  1. Pattern: Tree Breadth First Search

https://leetcode.com/problems/binary-tree-level-order-traversal/

https://leetcode.com/problems/binary-tree-level-order-traversal-ii/

https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/

https://leetcode.com/problems/minimum-depth-of-binary-tree/

https://leetcode.com/problems/inorder-successor-in-bst/ # Close, not exact

https://leetcode.com/problems/populating-next-right-pointers-in-each-node/ # Close, grokk assumes non-perfect tree

Next question is the same, but connect end nodes to the next level instead of null

https://leetcode.com/problems/binary-tree-right-side-view/

  1. Pattern: Tree Depth First Search
  2. Pattern: Two Heaps
  3. Pattern: Subsets
  4. Pattern: Modified Binary Search
  5. Pattern: Bitwise XOR
  6. Pattern: Top 'K' elements
  7. Pattern: K-way merge
  8. Pattern: 0/1 Knapsack
  9. Pattern: Topological Sort

https://leetcode.com/problems/kth-largest-element-in-an-array/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment