Skip to content
Reliable Data Engineering
Overview

Algorithms Practice: Patterns for the Coding Round

Many data engineering loops include one classic algorithms round. These problems are grouped by pattern, because recognising the pattern is most of the work. Learn the templates first in Algorithm patterns, then solve a pattern’s problems back to back until the template is automatic.

Every problem runs in your browser: write the function, press Run tests to see each test’s result next to the expected value, and press Debug to step through your code line by line.

Sliding Window

#ProblemDifficulty
01Longest Substring Without Repeating Charactersmedium
02Minimum Window Containing All Required Charactershard
03Shortest Burst Reaching a Throughput Targetmedium
04Longest Uniform Run With at Most k Replacementsmedium
05Find All Anagram Positionsmedium

Two Pointers (Opposite Ends)

#ProblemDifficulty
06Two Sum: Unsorted (Hash Map) and Sorted (Two Pointers)easy
073Sum: All Unique Triplets Summing to Zeromedium
08Container With the Most Watermedium
09Valid Palindrome After Normalisation (and With One Deletion)easy

Two Pointers (Same Direction)

#ProblemDifficulty
10Compact a Sorted Array In Place (Keep at Most k Copies)easy
11Move Zeroes and Remove Element (Stable Partition)easy

Fast & Slow Pointers (Floyd’s Cycle Detection)

#ProblemDifficulty
12Detect a Cycle and Find Where It Startsmedium
13Happy Number (Cycle Detection on a Function)easy
14Find the Duplicate Number Without Modifying the Arraymedium
15Palindrome Linked List in O(1) Spaceeasy

Prefix Sum

#ProblemDifficulty
16Range Sum Queries in 1D and 2D (Precompute Once, Answer in O(1))medium
17Subarray Sum Divisible by k (Prefix Sums + Remainders)medium
18Balance Point of a Partition (Pivot Index)easy
#ProblemDifficulty
19First and Last Position of a Value (Lower and Upper Bound)medium
20Integer Square Root (Binary Search on the Answer)easy
21Search a Rotated Sorted Array (and Find Its Minimum)medium
22Minimum Throughput to Finish a Backfill on Timemedium

Heap (Top-K and Greedy Merging)

#ProblemDifficulty
23Kth Largest Element: Heap vs Quickselectmedium
24K Closest Points to the Origin (Nearest Depots)medium
25Cheapest Way to Merge Sorted Filesmedium

Monotonic Stack

#ProblemDifficulty
26Days Until a Warmer Reading (Next Greater Element)medium
27Trapping Rain Waterhard
28Largest Rectangle in a Histogramhard
29Smallest Subsequence With Each Letter Oncehard

Kadane’s Algorithm (Best Subarray)

#ProblemDifficulty
30Maximum Subarray Sum, Including the Circular Casemedium
31Maximum Product Subarraymedium
32Best Time to Buy and Sell (One Trade and Unlimited Trades)easy

Merge Intervals

#ProblemDifficulty
33Insert an Interval Into a Sorted Schedulemedium
34Meeting Rooms: Any Conflict? How Many Rooms?medium
35Fewest Removals to Make Intervals Non-Overlappingmedium

Hashing, Stacks and Bit Tricks (Must-Know Classics)

#ProblemDifficulty
36Find the Missing ID (Sum, XOR and Their Trade-Offs)easy
37Valid Brackets (and the Minimum Fix)easy
38Valid Anagram and Group Anagramseasy
39Roman Numerals: Parse and Formateasy

Graphs: BFS, DFS and Union-Find

#ProblemDifficulty
40Count Connected Regions in a Grid (Islands)medium
41Shortest Path Through a Grid With Obstaclesmedium
42Merge Customer Records That Share an Email (Union-Find)medium

Dynamic Programming

#ProblemDifficulty
43Fewest Coins and Number of Ways (Unbounded Knapsack)medium
44Edit Distance for Fuzzy Matchinghard
45Longest Increasing Subsequence in O(n log n)medium

Backtracking and Tries

#ProblemDifficulty
46Subsets and Combination Sum (Backtracking)medium
47Autocomplete With a Trie (Top Suggestions by Frequency)medium