Reported October 2026
Ripplingsimulation

Best and Worst Camel Card Completions

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

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

Rippling reportedly asked this one in October 2026, and the naive read is where people lose points. "Best and Worst Camel Card Completions" looks like poker with a twist, but you're really filling up to five slots under a ranking rule. Pick the best and worst completion, return both as descending strings. The trap is that "worst" isn't just adding the lowest cards. Example 3 shows it: 1112 doesn't get 1s or 2s added, it gets a 3. If you have this OA in your inbox, learn the shape before you code. StealthCoder is the safety net if your mind goes blank mid-assessment.

The problem

A five-card hand uses ranks 1 through 9, with repeated ranks allowed. Hand categories from strongest to weakest are five of a kind, four of a kind, full house, three of a kind, two pair, one pair, and high card.
Within a category, compare groups by decreasing multiplicity and then decreasing rank. For example, compare the repeated rank before kickers; compare remaining kickers from high to low.
Given the ranks already present in a partial hand, add ranks until it has five cards. Return two canonical strings: the strongest possible completed hand and the weakest possible completed hand. Canonical strings list all five ranks in descending order.

Function
completeCamelCardHands(partial: String) → String[]

Examples
Example 1
partial = "99"
return = ["99999","99321"]
Five nines is strongest. A single pair of nines with the three lowest distinct kickers is weakest.
Example 2
partial = "12345"
return = ["54321","54321"]
The hand is already complete, so both answers are its canonical ordering.
Example 3
partial = "1112"
return = ["21111","32111"]
Adding 1 creates four of a kind. Adding the lowest new kicker 3 leaves three of a kind and is weakest.

Constraints
1 <= partial.length <= 5.
Every character in partial is a digit from 1 through 9.
Added ranks may repeat without a deck-count limit.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The input is at most five digits, so you could brute force: enumerate every way to add the missing cards (at most 9^4 = 6561 combos), score each hand, keep the max and min. That's safe and fast. The scoring key is the trick: sort rank groups by (count, rank) descending, then compare the resulting tuples, with category falling out of the count pattern. The pitfall is hand-rolling greedy rules for the worst case. Worst means avoiding new pairs by adding distinct unused ranks, and it picks the lowest ones available, which is why 99 becomes 99321 and 1112 becomes 32111. Greedy gets fiddly with partial hands that already hold a pair or trips. Enumeration with a comparator skips all of that. Build the canonical string by sorting descending. If you freeze on the comparator during the live OA, StealthCoder can surface it while you keep typing.

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 Best and Worst Camel Card Completions 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 Rippling's OA.

Rippling 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.

Best and Worst Camel Card Completions FAQ

What's the trick in Best and Worst Camel Card Completions?+

Brute force the completions and score each hand by its sorted (count, rank) group tuples. With at most four added cards and nine ranks, that's under 6600 hands. Track the max and min, then output each as a descending string. It avoids the greedy edge cases entirely.

Why isn't the worst hand just the lowest cards added?+

Because matching an existing rank can strengthen your hand. Example 3 starts with 1112, and adding another 1 or a 2 creates stronger shapes. The weakest completion adds the lowest rank that doesn't form a new pair or improve a group. Here that's 3, giving 32111.

How do I compare two hands correctly?+

Group ranks by frequency, then sort groups by count descending and rank descending. Compare those lists lexicographically. Higher count first means five of a kind beats four of a kind and so on, and ties fall to rank, then kickers. One comparator covers every category.

What edge cases should I test for this Rippling question?+

Test a full five-card input like 12345, where both answers are the same canonical ordering. Test a single card, a pair like 99, and trips like 1112. Also check that the output is sorted descending, since 99321 and 21111 depend on that format.

How do I prepare for this in 48 hours?+

Write the enumeration and scorer once, from scratch, and run the three examples. Then add a couple of your own cases like 5 and 4455. Practice frequency counting and tuple comparison in your language. If this exact problem shows up, you'll mostly be typing.

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

OA at Rippling?
Invisible during screen share
Get it