Find All Zip Rummy Melds
Reported by candidates from Zip's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Zip's April 2026 OA hands you a 10-card Rummy hand and asks for every set and run, including the shorter ones buried inside longer ones. That last clause is where people lose points. It's an enumeration problem with strict output ordering, not a search for the best meld. If you blank on the ordering rules or the subset logic, StealthCoder is the safety net running invisibly during the live assessment. But the problem is small, and you can own it before then.
The problem
Zip Rummy uses a 36-card deck. Each card has a rank from 1 to 9 and one suit: clubs (C), diamonds (D), hearts (H), or spades (S). You receive one 10-card hand as strings such as "7C". Find every meld of at least three cards that can be formed from this hand: A set contains cards of the same rank with different suits. A run contains cards of consecutive ranks in the same suit. Return all possible sets and runs, including shorter melds contained in longer ones. List cards within a set in suit order C, D, H, S, and cards within a run in increasing rank order. Return sets first in increasing rank order. Within one rank, return shorter sets before longer sets and then lexicographic suit order. Return runs next in increasing length, then starting rank, then suit order. Function findMelds(hand: String[]) → String[][] Examples Example 1 hand = ["1C","9C","8C","7C","5C","4C","9D","9S","1D","1H"] return = [["1C","1D","1H"],["9C","9D","9S"],["7C","8C","9C"]] The hand has two three-card sets and one three-card run in clubs. Example 2 hand = ["4C","2C","3C","1C","8D","6C","9D","9C","1D","1H"] return = [["1C","1D","1H"],["1C","2C","3C"],["2C","3C","4C"],["1C","2C","3C","4C"]] The four consecutive clubs make two runs of length three and one run of length four. Constraints hand.length == 10. Every card is unique and belongs to the 36-card deck described above.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Split it into two passes. For sets, group cards by rank. For each rank with three or more cards, generate every subset of size 3 and up, in suit order C, D, H, S. Sort by rank, then size, then lexicographic suits. For runs, group by suit, sort by rank, then for each starting rank and each length of 3 or more, check that every consecutive rank is present. The edge case that breaks a naive solution is returning only the maximal meld. Example 2 shows a four-card run also emits both three-card runs. Another trap is sorting strings, because rank is a single digit here but you should still compare numerically. Also, 4 cards of one rank means four 3-card subsets plus one 4-card set. With only 10 cards, brute force is fine. If you freeze on the output order during the live OA, StealthCoder is your hedge, but build the sort keys first.
If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.
You can drill Find All Zip Rummy Melds 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 StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Zip's OA.
Zip 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.
Find All Zip Rummy Melds FAQ
What's the trick in the Zip Rummy melds problem?+
Emit every valid meld, not just the longest. For sets, take all subsets of size 3 or more from cards sharing a rank. For runs, take every contiguous window of length 3 or more in a suit. Then sort exactly by the stated rules.
How hard is this Zip OA question really?+
Easy to medium. The algorithm is simple enumeration on 10 cards, so performance is a non-issue. The difficulty is getting the ordering and the overlapping shorter melds exactly right, which is where most wrong answers come from.
How should I order the output?+
Sets come first, sorted by rank, then by size (shorter first), then by suit order. Runs come next, sorted by length, then starting rank, then suit. Build tuple sort keys for each group and sort once instead of relying on generation order.
Do I need dynamic programming or backtracking?+
No. The hand has only 10 cards, so direct enumeration works. A rank with 4 cards gives at most 5 sets. A suit with up to 9 ranks gives a small number of windows. Simple loops and a sort are enough.
How do I prepare for this in 48 hours?+
Write findMelds from scratch and test both examples. Then test a rank with four cards and a suit with five consecutive ranks. Check that shorter melds inside longer ones appear. Spend your remaining time on the custom sort comparator.