FastPrepBest and Worst Camel Card Completions
Problems/Best and Worst Camel Card Completions

Best and Worst Camel Card Completions

Rippling logoRippling● HardFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report defines five-card category comparison and a follow-up that asks for the strongest and weakest completion of a partial hand, explicitly allowing brute force. Canonical descending output removes equivalent-order ambiguity.

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.

Interviewer Follow-ups

A recent report describes an AI-enabled coding round in two parts. The first part compares two hands. The second part, practiced here, asks for the best and worst hands. After writing a brute-force solution that tries every completion, the candidate talked through with the interviewer how to make it faster.

This follow-up is for discussion. The tests check only the returned hands.

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.

More Rippling problems

  • Stateful Log Transform and SearchPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Dependency-Aware Task SchedulerPHONE SCREEN · Seen Nov 2026
  • Filter, Sort, and Deduplicate Scheduled TasksPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
All Rippling interview questionsSee Rippling hiring insights
Saved
public String[] completeCamelCardHands(String partial) {
    // Write your solution here.
}
Checking account…