MEDIUMasked at 7 companies

Combinations

A medium-tier problem at 73% community acceptance, tagged with Backtracking. Reported in interviews at Amazon and 6 others.

Founder's read

Combinations shows up constantly in Amazon, Google, and Meta assessments, and most candidates blank on it despite the problem seeming straightforward. You're given n and k, and you need to return all k-length combinations from 1 to n. The acceptance rate sits at 73 percent, which sounds high until you realize that's because most people who attempt it already know backtracking. If you hit this live and haven't drilled the recursive pattern, you'll lose 15 minutes spinning in circles. StealthCoder solves it invisibly in seconds, leaving you time for the next problem.

Companies asking
7
Difficulty
MEDIUM
Acceptance
73%

Companies that ask "Combinations"

If this hits your live OA

Combinations is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE.

Get StealthCoder
What this means

The trap is thinking iteratively or trying to use nested loops. Once you see it requires backtracking, the solution clicks, but getting there under pressure is the real test. You build combinations by recursively choosing elements, tracking your current combination, and backtracking when you've hit k elements. The pattern is: for each number in the remaining range, add it to the current combination, recurse on the next numbers, then remove it and continue. Most candidates either forget to backtrack (and mutate the result list), or they don't understand how to slice the range to avoid duplicates. Apple and Microsoft both ask this frequently, and it's a filter for whether you actually understand recursion or just memorized DFS. StealthCoder is your hedge if the backtracking syntax or the range-slicing logic escapes you mid-assessment.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Combinations recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Combinations interview FAQ

Why can't I just use nested loops.+

You'd need k nested loops, and k is variable. That doesn't scale. Backtracking lets you handle any k with one recursive function. The inner loop runs at each depth level, not stacked ahead of time.

Is this still asked at big tech companies.+

Yes. Amazon, Google, Meta, Apple, and Microsoft all ask Combinations or variations. It's a canonical backtracking problem and shows up in phone screens and online assessments regularly.

What's the main mistake people make.+

Forgetting to backtrack. They add elements to the result, recurse, but don't remove the element before trying the next one. Result is duplicate or malformed combinations. Also slicing the range wrong, which causes duplicates or missing combos.

How does this relate to other backtracking problems.+

Combinations is the template for permutations, subsets, and letter combinations. Once you own the recursive choice-recurse-unchoose pattern here, you can adapt it to any backtracking problem. It's foundational.

What's the time complexity.+

O(n choose k times k), because there are C(n,k) combinations and you do O(k) work per combination to build and store it. For large n and mid-range k, this grows quickly, but that's inherent to the problem, not a flaw in your algorithm.

Want the actual problem statement? View "Combinations" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.