Android & iPhone apps are coming soon. Log in for a plan and reminders made for you β†’

Exercises

Practise every idea

One small exercise for each idea in β€œKnow these before you start”, solved in the editor (Python, Java or C++) with tests and hints. Each sits at the end of its lesson; passing it marks the idea as known on the path and on every problem that needs it.

0/40 concepts practised

1.Arrays & Strings

On the path β†’
  1. Second-largest distinct elementPractises: Indexing and walking through an arrayPractise ✎
  2. Count how often each number appearsPractises: Counting with a hash mapPractise ✎
  3. Remove duplicate characters, keep the firstPractises: A set for β€œhave I seen this?”Practise ✎
  4. Reverse the order of wordsPractises: Building a new string or array as the answerPractise ✎

2.Two Pointers

On the path β†’
  1. Check if a string is a palindromePractises: Two pointers from opposite endsPractise ✎
  2. Move zeros to the endPractises: Two pointers moving the same wayPractise ✎
  3. Closest pair of numbersPractises: When sorting first unlocks the patternPractise ✎

3.Sliding Window

On the path β†’
  1. Most vowels in k lettersPractises: Fixed-size sliding windowsPractise ✎
  2. Shortest stretch reaching a targetPractises: Variable-size sliding windowsPractise ✎
  3. Longest stretch with two kinds of letterPractises: Tracking what's inside a windowPractise ✎
  1. Remove adjacent pairsPractises: Stacks for matching pairsPractise ✎
  2. Next greater numberPractises: Monotonic stacks: the next greater elementPractise ✎
  3. Preorder without recursionPractises: Replacing recursion with your own stackPractise ✎

6.Linked List

On the path β†’
  1. Add up a linked listPractises: Walking a linked listPractise ✎
  2. Reverse the first k nodesPractises: Reversing a linked listPractise ✎
  3. k-th node from the endPractises: Fast and slow pointers on a linked listPractise ✎
  1. Postorder traversalPractises: Depth-first traversal: preorder, inorder, postorderPractise ✎
  2. Sum of each levelPractises: Breadth-first traversal with a queuePractise ✎
  3. Is it in the BST?Practises: Height, depth and binary search treesPractise ✎

8.Heap / Priority Queue

On the path β†’
  1. Sort with a heapPractises: What a heap keeps on topPractise ✎
  2. Connect the ropes cheaplyPractises: Why heap push and pop are O(log n)Practise ✎
  3. Sum of the k largestPractises: Keeping only the k best with a heapPractise ✎

9.Backtracking

On the path β†’
  1. Palindrome, recursivelyPractises: Recursion: the base case and the call stackPractise ✎
  2. Every binary string of length nPractises: Backtracking: choose, explore, un-choosePractise ✎
  3. Binary strings without 11Practises: Pruning: stop branches that can't workPractise ✎
  1. How connected is each node?Practises: Representing graphs: adjacency lists and gridsPractise ✎
  2. Fewest hops between two nodesPractises: Graph BFS and DFSPractise ✎
  3. Count the connected groupsPractises: The visited setPractise ✎

11.Dynamic Programming

On the path β†’
  1. Tribonacci, fastPractises: Memoization: recursion that remembersPractise ✎
  2. Cheapest path through a gridPractises: Defining the DP statePractise ✎
  3. A row of Pascal's trianglePractises: Bottom-up DP: filling a tablePractise ✎

12.Greedy & Intervals

On the path β†’
  1. Can you attend every meeting?Practises: Sort first, then decide in one passPractise ✎
  2. Fewest coins for changePractises: When the locally best choice is safePractise ✎
  3. Total length coveredPractises: Merging and overlapping intervalsPractise ✎

13.Bit Manipulation & Math

On the path β†’
  1. Is it a power of two?Practises: Binary numbers and AND, OR, XORPractise ✎
  2. Binary string to numberPractises: Bit shiftsPractise ✎
  3. Find the extra letterPractises: XOR and other bit tricksPractise ✎