Reported March 2025
Scale AIsimulation

Best Poker Category with a Joker

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

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

Scale AI reported this one in March 2025, and it looks like a poker problem until you read it twice. It's really a small case analysis: five cards, at most one wildcard, seven fixed categories. No search, no DP. The Joker either does nothing or you try every rank and suit it could become and keep the best result. If you've got the OA coming up, the trap isn't difficulty. It's getting the ranking order and the ace-low straight right under pressure. StealthCoder sits invisibly on your screen as a safety net if you blank mid-assessment, but the logic below is short enough to hold in your head.

The problem

For this exercise, assume cards contains exactly five poker cards. A non-Joker card is encoded as its rank followed by its suit.
Ranks are 2 3 4 5 6 7 8 9 T J Q K A.
Suits are C D H S.
At most one entry is the literal JOKER.
The Joker may represent any rank and suit; as a wildcard it may supply a fifth card of an existing rank. Return the strongest category that the hand can achieve, using this order:
FIVE_OF_A_KIND
STRAIGHT_FLUSH
FOUR_OF_A_KIND
FULL_HOUSE
FLUSH
STRAIGHT
NONE
A straight contains five consecutive ranks. Ace may be high in T-J-Q-K-A or low in A-2-3-4-5. A straight flush is both a straight and a flush. Only the listed categories are returned.

Function
bestPokerCategory(cards: String[]) → String

Examples
Example 1
cards = ["9C","TC","JC","QC","JOKER"]
return = "STRAIGHT_FLUSH"
The Joker can become KC, producing the club straight flush 9-T-J-Q-K.
Example 2
cards = ["AS","AH","AD","AC","JOKER"]
return = "FIVE_OF_A_KIND"
The four Aces plus a Joker form five of a kind, the strongest reported category.
Example 3
cards = ["2C","2D","7H","9S","KC"]
return = "NONE"
The hand does not satisfy any listed category. Pair is deliberately not one of the possible return values.

Constraints
cards.length == 5.
Every non-Joker card uses a valid rank and suit.
Non-Joker cards are distinct.
At most one card is JOKER.
Return exactly one of the seven documented category strings.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Reduce it to brute force. If there's no Joker, classify the five cards directly. If there is one, loop over all 13 ranks and 4 suits, substitute, classify, and keep the strongest category by the given order. That's at most 52 tiny evaluations. Classification uses a rank count map and a suit set. Five of a kind needs a count of 5, which only happens with the Joker. Four of a kind is a max count of 4. Full house is counts 3 and 2. Flush is one suit. Straight is five distinct ranks that are consecutive, and you must also test the ace-low set A,2,3,4,5. Straight flush is straight plus flush. The common pitfall is returning pair or two pair, which aren't valid outputs, and checking categories in the wrong order. Check from strongest down and return the first match. Distinct non-Joker cards means duplicates of one exact card can't appear, though the Joker substitute might duplicate one, which is fine. If you freeze during the live OA, StealthCoder is the hedge.

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 Poker Category with a Joker 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 Scale AI's OA.

Scale AI 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 Poker Category with a Joker FAQ

What's the trick to Best Poker Category with a Joker?+

Don't reason about what the Joker should be. Try all 52 rank and suit substitutions, classify each full hand, and keep the strongest category. With only five cards, brute force is trivially fast and avoids missing edge cases.

How do I handle the ace-low straight?+

Map ranks to numbers 2 through 14. Sort the distinct values and check if max minus min equals 4 with five distinct values. Separately check whether the set equals {14,2,3,4,5}. Either one counts as a straight.

Do I need to return pair or two pair?+

No. The problem says only the listed seven categories are returned. A hand with just a pair or two pair returns NONE. Example 3 shows this with a pair of twos returning NONE.

In what order should I check categories?+

Follow the given strength order: five of a kind, straight flush, four of a kind, full house, flush, straight, then NONE. Return the first one that matches. Check for the Joker case by taking the best result across substitutions.

How do I prep for this in 48 hours?+

Write the classifier once with a rank count map and a suit set. Test it on the three examples plus an ace-low straight and a Joker full house. Then add the Joker loop. It's under 60 lines, so one clean practice run is enough.

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

OA at Scale AI?
Invisible during screen share
Get it