Reported September 2026
Metabacktracking

Partition a Card Deck into Fifteens

Reported by candidates from Meta's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Meta OA. Under 2s to a working solution.
Founder's read

The mistake that sinks a first attempt on this Meta OA, reported in September 2026, is treating it like a greedy pairing problem. Sort, grab the biggest card, find two friends, repeat. It fails fast. The task is to split up to 36 cards into triples that each sum to 15, and every card must be used. Values only run 1 to 9, which is the clue that matters. This is a counting plus backtracking problem wearing a DP costume. If you blank mid-assessment, StealthCoder runs invisibly on your desktop and can hand you the approach while you type.

The problem

Given the visible values of an entire card deck, decide whether every card can be consumed by partitioning the deck into disjoint groups of exactly three cards whose values sum to 15.
Cards are distinct physical cards even when values repeat. Every card must appear in exactly one group.

Function
canPartitionIntoFifteens(cards: int[]) → boolean

Examples
Example 1
cards = [1,5,9,2,6,7]
return = true
The deck can be grouped as (1,5,9) and (2,6,7).
Example 2
cards = [1,1,1]
return = false
The only triple sums to 3.
Example 3
cards = [5,5,5,5,5,5]
return = true
Two identical triples each sum to 15.

Constraints
0 <= cards.length <= 36 and its length is divisible by 3.
1 <= cards[i] <= 9.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is that values are only 1 to 9, so don't track individual cards. Track a count array of size 10. Take the smallest value still remaining, try every pair (b, c) with b <= c and b >= a such that a+b+c = 15 and counts allow it, decrement, recurse. Always anchoring on the smallest remaining value kills duplicate orderings. Memoize on the count tuple, since at most 36 cards across 9 values gives a small state space. Quick prunes: length not divisible by 3 returns false, total sum must equal 5 times the number of triples, and the empty deck returns true. The pitfall is picking triples in arbitrary order, which explodes the search, or using greedy on largest first, which gives wrong answers. Valid triples are few: (1,5,9), (2,4,9), (2,5,8), (3,3,9), (5,5,5) and so on. If the recursion gets tangled live, StealthCoder is the hedge that gives you a clean version.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Partition a Card Deck into Fifteens cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Meta's OA.

Meta reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Partition a Card Deck into Fifteens FAQ

What's the trick for Partition a Card Deck into Fifteens?+

Count occurrences of each value 1 to 9, then always build a triple around the smallest remaining value. That removes duplicate orderings. Try the two other values that make 15, check counts, decrement, and recurse. Memoizing on the count array keeps it fast.

Does greedy work here?+

No. Taking the largest card and pairing it with whatever fits can strand cards that would have worked in a different grouping. You need backtracking so a failed choice gets undone and another triple is tried.

What quick checks should I add before searching?+

Return true for an empty deck. Return false if the length isn't divisible by 3. Return false if the total sum isn't 15 times the number of triples. These cheap checks reject many inputs before any recursion starts.

How hard is this really?+

Medium. The idea is short once you see the count array, but the dedupe logic trips people. Expect the harder part to be avoiding repeated states, not coding the recursion. Write the base case and the smallest-first rule before anything else.

How do I prepare in 48 hours for a Meta OA like this?+

Practice two or three backtracking with memoization problems where the input has a small value range, since that's the shape here. Write the count-array version from scratch once. Then test your solution on the three given examples and an all-5s deck.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Meta.

OA at Meta?
Invisible during screen share
Get it