Cloze

Quests 10 chapters · 75 problems

The Classic 75

The classic interview list, one stage at a time.

Seventy-five problems in ten chapters, from arrays to heaps. Each stage has four trials: fill the blanks, recall the key lines, rebuild a loop or a block, then write the whole function.

Try Arrays, the first chapter, without an account. Create a free account to open every problem and keep your stars.

Arrays

Hash maps, prefix products and the first habits of a careful solver.
10 problems
  1. 1 Two Sum Easy Hash map Up next 1Fill 2Recall 3Rebuild 4Write

    Find the two numbers in nums that add up to target, and return their indices.

  2. 2 Best Time to Buy and Sell Stock Easy One pass Ready 1Fill 2Recall 3Rebuild 4Write
  3. 3 Contains Duplicate Easy Hash set Ready 1Fill 2Recall 3Rebuild 4Write
  4. 4 Product of Array Except Self Medium Prefix and suffix products Ready 1Fill 2Recall 3Rebuild 4Write
  5. 5 Maximum Subarray Medium Running best Ready 1Fill 2Recall 3Rebuild 4Write
  6. 6 Maximum Product Subarray Medium Running best and worst Ready 1Fill 2Recall 3Rebuild 4Write
  7. 7 Find Minimum in Rotated Sorted Array Medium Binary search Ready 1Fill 2Recall 3Rebuild 4Write
  8. 8 Search in Rotated Sorted Array Medium Binary search Ready 1Fill 2Recall 3Rebuild 4Write
  9. 9 3Sum Medium Sort and two pointers Ready 1Fill 2Recall 3Rebuild 4Write
  10. 10 Container With Most Water Medium Two pointers Ready 1Fill 2Recall 3Rebuild 4Write

Binary

Bits: counting, flipping and adding without a plus.
5 problems
  1. Sum of Two Integers Medium Bit manipulation Free account
  2. Number of 1 Bits Easy Bit manipulation Free account
  3. Counting Bits Easy Dynamic programming on bits Free account
  4. Missing Number Easy Xor Free account
  5. Reverse Bits Easy Bit manipulation Free account

Dynamic programming

Break a problem into smaller ones you have already solved.
11 problems
  1. Climbing Stairs Easy Dynamic programming (Fibonacci) Free account
  2. Coin Change Medium Dynamic programming over amounts Free account
  3. Longest Increasing Subsequence Medium Dynamic programming, looking back Free account
  4. Longest Common Subsequence Medium Dynamic programming on two strings Free account
  5. Word Break Medium Dynamic programming over starts of the string Free account
  6. Combination Sum IV Medium Dynamic programming over totals Free account
  7. House Robber Medium Dynamic programming Free account
  8. House Robber II Medium Dynamic programming, twice Free account
  9. Decode Ways Medium Dynamic programming over starts of the string Free account
  10. Unique Paths Medium Dynamic programming on a grid Free account
  11. Jump Game Medium Greedy, furthest reach Free account

Graphs

Search a world of connected things: islands, courses, clones.
7 of 8 written
  1. Course Schedule Medium Topological sort (Kahn's algorithm) Free account
  2. Pacific Atlantic Water Flow Medium Search uphill from each ocean Free account
  3. Number of Islands Medium Depth-first search, sinking each island Free account
  4. Longest Consecutive Sequence Medium Hash set, counting from each run's start Free account
  5. Alien Dictionary Hard Topological sort, earliest letter first Free account
  6. Graph Valid Tree Medium Union-find Free account
  7. Number of Connected Components in an Undirected Graph Medium Union-find Free account

Intervals

Ranges on a line: merge them, insert into them, schedule around them.
5 problems
  1. Insert Interval Medium Merge as you scan Free account
  2. Merge Intervals Medium Sort, then merge Free account
  3. Non-overlapping Intervals Medium Greedy, by end Free account
  4. Meeting Rooms Easy Sort and compare neighbours Free account
  5. Meeting Rooms II Medium Sorted starts and ends Free account

Linked lists

Pointers you rewire by hand.
5 of 6 written
  1. 40 Reverse Linked List Easy Linked list Ready 1Fill 2Recall 3Rebuild 4Write
  2. Merge Two Sorted Lists Easy Linked list, dummy head Free account
  3. Merge k Sorted Lists Hard Divide and conquer, merging in pairs Free account
  4. Remove Nth Node From End of List Medium Two pointers, n apart Free account
  5. Reorder List Medium Find the middle, reverse, weave Free account

Matrices

Grids: walk them, rotate them, search them.
4 problems
  1. Set Matrix Zeroes Medium Mark the rows and columns first Free account
  2. Spiral Matrix Medium Shrinking edges Free account
  3. Rotate Image Medium Transpose, then reverse each row Free account
  4. Word Search Medium Backtracking on a grid Free account

Strings

Windows, anagrams, brackets and palindromes.
9 of 10 written
  1. Longest Substring Without Repeating Characters Medium Sliding window with last positions Free account
  2. Longest Repeating Character Replacement Medium Sliding window with counts Free account
  3. Minimum Window Substring Hard Sliding window with counts Free account
  4. 53 Valid Anagram Easy Counting Ready 1Fill 2Recall 3Rebuild 4Write
  5. Group Anagrams Medium Hash map by sorted letters Free account
  6. 55 Valid Parentheses Easy Stack Ready 1Fill 2Recall 3Rebuild 4Write
  7. Valid Palindrome Easy Two pointers Free account
  8. Longest Palindromic Substring Medium Expand around each centre Free account
  9. Palindromic Substrings Medium Expand around each centre Free account

Trees

Recursion on branching shapes, and search trees.
13 of 14 written
  1. Maximum Depth of Binary Tree Easy Recursion (depth-first) Free account
  2. Same Tree Easy Recursion on two trees at once Free account
  3. Invert Binary Tree Easy Recursion Free account
  4. Binary Tree Maximum Path Sum Hard Depth-first search, gains from each side Free account
  5. Binary Tree Level Order Traversal Medium Breadth-first search Free account
  6. Subtree of Another Tree Easy Recursion, comparing at every node Free account
  7. Construct Binary Tree from Preorder and Inorder Traversal Medium Divide and conquer with an index map Free account
  8. Validate Binary Search Tree Medium Recursion with bounds Free account
  9. Kth Smallest Element in a BST Medium In-order walk with a stack Free account
  10. Lowest Common Ancestor of a Binary Search Tree Medium Walk down a search tree Free account
  11. Implement Trie (Prefix Tree) Medium Trie of nested maps Free account
  12. Design Add and Search Words Data Structure Medium Trie, with a search that branches at a dot Free account
  13. Word Search II Hard Trie and backtracking Free account

Heaps

Always know the smallest, largest or middle.
3 problems
  1. Merge k Sorted Lists Hard Divide and conquer, merging in pairs Free account
  2. Top K Frequent Elements Medium Bucket sort by count Free account
  3. Find Median from Data Stream Hard Sorted list, binary search to insert Free account