Camel Cards
Reported by candidates from Rippling's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Rippling reportedly asked this one in July 2026, and it looks like a card game but it's really a counting problem with a custom comparator. Camel Cards gives you two four-card hands, digits 1 through 9, and asks who wins. Count how often each digit appears, map that frequency shape to a rank, then break ties by comparing cards right to left. That's the whole thing. The twist is the extensibility ask, so your hand-type logic can't be a tangled if-else pile. If you blank on the structure during the live OA, StealthCoder runs invisibly as a safety net while you finish.
The problem
Camel Cards is a simplified two-player card game. You are given two strings, hand1 and hand2, representing the players' four-card hands. Each card is labeled with a digit from 1 through 9, where 9 is highest. Hand Types From strongest to weakest: Four of a kind: all four cards are equal, such as 9999. Two pair: two cards of one value and two cards of another value, such as 2332. Three of a kind: three equal cards and one different card, such as 9998. One pair: two equal cards and two other distinct cards, such as 5233. High card: all four cards are distinct, such as 2345. Ordering Rules A stronger hand type always wins. If both hands have the same type, compare their cards from right to left, which is from most recently dealt to first dealt. Do not sort the cards. At the first differing position, the hand with the higher card wins. If all four cards are equal, the result is a tie. Return "HAND_1" if hand1 wins, "HAND_2" if hand2 wins, or "TIE". Design the hand-type evaluation so that more hand types can be added later. Function evaluate(hand1: String, hand2: String) → String Examples Example 1 hand1 = "2332" hand2 = "2442" return = "HAND_2" Both hands are two pair. Comparing from right to left, the final cards are tied at 2, then hand2 has 4 while hand1 has 3. Constraints hand1.length() = hand2.length() = 4 Every character in hand1 and hand2 is a digit from 1 through 9.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is the frequency signature. Count each digit, sort the counts descending, and you get a shape: [4] is four of a kind, [2,2] is two pair, [3,1] is three of a kind, [2,1,1] is one pair, [1,1,1,1] is high card. Map each shape to a numeric rank. Compare ranks first. If they match, walk indexes 3 down to 0 and compare the raw characters at the first difference. The common pitfall is sorting the cards before the tiebreak, which the statement explicitly forbids. Another is comparing left to right out of habit. For the extensibility requirement, keep a rank table or a list of (predicate, rank) rules so a new hand type is one new entry, not a rewrite. Total work is constant since hands have four cards. If you freeze on the signature idea in the live OA, StealthCoder is the hedge that surfaces it.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Camel Cards 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. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Rippling's OA.
Rippling reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Camel Cards FAQ
How hard is Camel Cards really?+
Easy to medium. The logic is short, but the details bite: right-to-left tiebreak, no sorting of the original hand, and a clean design for adding hand types. Most failures come from misreading the ordering rules, not from algorithm difficulty.
What's the trick to classifying hands?+
Count digit frequencies, then sort the counts descending. The resulting list like [2,2] or [3,1] uniquely identifies each hand type. Map each list to a rank number and you can compare hands with a single integer comparison before any tiebreak.
How do I handle the tiebreak correctly?+
Only when ranks are equal, loop from index 3 down to 0 on the original, unsorted strings. At the first position where characters differ, the higher digit wins. Digit characters compare correctly as characters since they're all single digits 1 through 9. If none differ, return TIE.
What does 'design for more hand types' mean in practice?+
Avoid hardcoding a long if-else chain inside evaluate. Use a lookup from count signature to rank, or an ordered list of rule objects. Adding a type then means adding one entry. Mention this in a comment or short explanation, since it's likely part of the grading.
How do I prepare for this in 48 hours?+
Practice frequency counting with a hash map, custom comparators, and tiebreak loops. Write this exact problem once from scratch, then test edge cases: all equal hands, same type with a difference only in the first card, and two pair versus three of a kind.