top of page
Search
KSum
The KSum problem generalizes 2Sum, 3Sum, and 4Sum into a flexible recursive solution that can find all unique combinations of k numbers in an array that sum to a target. It’s a fantastic problem for practicing recursion, backtracking, and thinking about how to build modular solutions that scale with complexity. Once you’ve nailed KSum, you can solve any of the others as special cases.
May 28, 20255 min read
4Sum
This is a great follow-up to 2Sum and 3Sum. It challenges you to apply the same two-pointer strategy but adds complexity by requiring a quadruplet instead of a pair or triplet. This kind of problem comes up when you're working on systems that require combinatorial sum checks, like budgeting scenarios, fraud detection with transaction records, or even algorithmic trading strategies. The key here is optimization over brute-force enumeration.
May 27, 20255 min read
3Sum Closest
This is a great warm-up for array and two-pointer problems. It’s similar to the classic 3Sum, but instead of finding a triplet that adds to a specific number, we need the closest possible sum. This introduces an optimization twist that requires careful comparison and pointer movement, making it an excellent real-world scenario—think of situations where you need to get as close as possible to a threshold value without hitting it exactly, such as budget planning or resource all
May 26, 20254 min read
3Sum
Finding triplets that sum to zero is a foundational exercise in two-pointer techniques, sorting, and careful duplicate handling. The “3Sum” problem tests your ability to combine sorting with pointer sweeps to achieve O(n²) performance.
May 25, 20256 min read
Container With Most Water
Determining the maximum water a container can hold between vertical lines is foundational in graphics rendering, fluid simulations, and two-pointer optimizations. The “Container With Most Water” problem challenges you to squeeze the best area in O(n) time.
May 21, 20253 min read
Merge k Sorted Lists
Combining multiple sorted streams into one sorted output is a classic challenge faced in database merge operations, log file aggregation, and external sorting. The “merge K sorted lists” problem tests your ability to coordinate multiple pointers, leverage priority data structures, and keep everything running in optimal time.
May 12, 20255 min read
Missing Number
When you need to find the one missing entry in a sequence—say missing log IDs, seats, or data packets— Missing Number is the classic...
Apr 28, 20253 min read
Top K Frequent Elements
Finding the most frequent items in a dataset is a common real-world task—think trending topics in social media, most visited pages on a...
Apr 28, 20254 min read
Intersection of Two Arrays
Finding the intersection of two arrays - i.e. the common elements between two lists - is a real-world task you’ll do when reconciling...
Apr 28, 20254 min read
Kth Largest Element in an Array
Finding the Kth largest element in an array is a practical problem you’ll face when you need to compute statistics on large...
Apr 28, 20254 min read
Sort Colors (Dutch National Flag) Problem
Sorting an array of red, white, and blue objects—represented by 0, 1, and 2—is a classic real-world task when you need to group items by...
Apr 24, 20253 min read
Merge Two Sorted Arrays
Merging two sorted arrays is a super-practical task you’ll do whenever you need to combine sorted streams—think merging log files, time...
Apr 22, 20253 min read
Majority Element
Finding the majority element—an item that appears more than half the time in an array—is a classic warm‑up that’s surprisingly useful in...
Apr 18, 20253 min read
Longest Common Prefix
Finding the longest common prefix among an array of strings is a classic warm‑up. It pops up in real‑world scenarios like building...
Apr 18, 20253 min read
Deriving KMP in Real Time
I’m staring at my whiteboard, fresh off writing the brute‑force substring search: two nested loops, compare needle at every haystack...
Apr 17, 20254 min read
Needle In a Haystack - Part 1
Searching for a substring within a larger string is a fundamental task in many real‑world applications—think text editors, search...
Apr 17, 20253 min read
Valid Palindrome - A Warm Up
Checking whether a string is a palindrome—ignoring punctuation, spaces, and case—is a classic coding interview warm‑up. It’s directly...
Apr 17, 20253 min read
Move Zeroes – A Warm‑Up
Let’s walk through one of the classic warm-up problems you might face in a coding interview or on the job: moving all the zeroes in an...
Apr 15, 20253 min read
Reverse an Array In Place
In today’s practice question, we talk through the reverse an array in place question - no extra arrays allowed. Problem Statement Given...
Apr 15, 20254 min read
Rotate an Array by k Steps
Rotating an array in place is a classic warm‑up that tests your ability to manipulate arrays, handle wrap‑around indexing, and optimize...
Apr 15, 20253 min read
bottom of page