Reported September 2026
Coinbasebit manipulation

Select a Fee-Maximizing Dependency-Closed Block

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

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

Coinbase reported this one in September 2026, and the setup is a mempool where a transaction only goes in the block if every recursive parent goes in too. Fees, sizes, a capacity of at most 100, and at most 20 transactions. That's a knapsack with dependency closure, and the constraints are practically begging for a bitmask. The tiebreaks are where people lose points: max fee, then smaller total size, then the lexicographically smaller identifier sequence. If you blank during the live OA, StealthCoder runs invisibly as a safety net. Know the shape before you open the problem.

The problem

A mempool contains transactions with unique identifiers, nonnegative fees, positive sizes, and zero or more parent transaction identifiers. A block may include a transaction only when it also includes every recursive parent.
Given a block-size capacity, return the dependency-closed subset with maximum total fee. The dependency graph is acyclic, and every parent appears earlier than its child in the input. Return selected identifiers in input order, which is therefore topological.
If several valid subsets have the same total fee, choose the one with smaller total size. If still tied, choose the lexicographically smaller sequence of returned identifiers. Return an empty array when no transaction fits.

Function
selectBlockTransactions(ids: String[], fees: int[], sizes: int[], parents: String[][], capacity: int) → String[]

Examples
Example 1
ids = ["p","c","x"]
fees = [1,10,7]
sizes = [40,40,60]
parents = [[],["p"],[]]
capacity = 80
return = ["p","c"]
The parent-child package pays fee 11 in size 80, beating the independent transaction's fee 7.
Example 2
ids = ["a","b","c"]
fees = [5,5,10]
sizes = [50,50,100]
parents = [[],[],[]]
capacity = 100
return = ["a","b"]
Both [a,b] and [c] earn fee 10 with size 100. The returned identifier sequence [a,b] is lexicographically smaller.
Example 3
ids = ["a","b"]
fees = [3,100]
sizes = [60,50]
parents = [[],["a"]]
capacity = 100
return = ["a"]
The child cannot fit together with its required parent, while the parent alone is valid.

Constraints
0 <= ids.length <= 20.
ids.length = fees.length = sizes.length = parents.length.
Identifiers are unique non-empty strings.
0 <= fees[i] <= 10^9 and 1 <= sizes[i] <= 100.
0 <= capacity <= 100.
Every named parent exists at a smaller input index, and parent lists contain no duplicates.

Reported by candidates. Source: FastPrep

Pattern and pitfall

With n at most 20, enumerate all 2^n subsets. For each mask, check closure: for every selected transaction, all of its parents must be selected too. Precompute a parent mask per index (direct parents are enough, since checking every selected node covers the recursion). Then sum fees and sizes, skip if size exceeds capacity, and compare against the best. Compare by higher fee, then smaller size, then lexicographic order of the id list in input order. Fees reach 10^9 across 20 items, so use 64-bit sums. The common pitfall is the tiebreak. Example 2 shows [a,b] beating [c] on lexicographic order, so compare the actual strings, not the indices. The empty selection is the default answer when nothing fits. Zero-fee items can still matter for tiebreaks, so don't filter them. If you freeze on the comparison logic during the live OA, StealthCoder is the hedge that gets you a working comparator fast.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Select a Fee-Maximizing Dependency-Closed Block 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 for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Coinbase reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Select a Fee-Maximizing Dependency-Closed Block FAQ

What's the trick in this Coinbase block selection problem?+

Brute force over bitmasks. With at most 20 transactions, 2^20 subsets is about a million, which is fine. For each mask, verify every selected transaction has its parents in the mask, then check capacity and compare against the best so far.

Do I need to compute recursive parents explicitly?+

No. If you check that every selected transaction's direct parents are also selected, closure holds transitively. A grandparent is required by the parent, which is itself checked. A direct-parent bitmask per index is enough and keeps the closure check to one AND operation.

How do the tiebreak rules work?+

Compare total fee first, higher wins. On a tie, smaller total size wins. On a further tie, compare the id sequences in input order lexicographically as strings. Example 2 shows [a,b] beating [c] even though both earn 10 at size 100.

Could a DP replace the bitmask here?+

Tree-knapsack style DP is possible for forests, but this is a DAG with multiple parents, so closure sharing makes it messy. The 20-item limit signals that the intended solution is subset enumeration. Don't overengineer it.

How do I prepare for this in 48 hours?+

Practice bitmask subset enumeration and writing a clean comparator with multi-level tiebreaks. Test the three given examples plus an empty input and a case where nothing fits. Watch the 64-bit sum for fees up to 10^9. That covers nearly every failure mode.

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

OA at Coinbase?
Invisible during screen share
Get it