FastPrepBest Poker Category with a Joker
Problems/Best Poker Category with a Joker

Best Poker Category with a Joker

Scale AI logoScale AI● MediumFULLTIMENEW GRADINTERNPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Scale AI onsite interview. One report sorts hands into poker categories and adds a Joker. Another describes a task with 52 cards and rule variants for straight flush, straight and four of a kind, but it does not give the changed rules or the exact action. We chose how to sort hands, how to write a five-card hand, that the strongest category wins, how the Ace works, and the output when nothing matches. The optional Joker extension comes from the first report. Our version is about 84% the same as the reported question.

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:

  1. FIVE_OF_A_KIND
  2. STRAIGHT_FLUSH
  3. FOUR_OF_A_KIND
  4. FULL_HOUSE
  5. FLUSH
  6. STRAIGHT
  7. 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.

More Scale AI Onsite Interview questions

  • Task Scheduler with DependenciesONSITE INTERVIEW · Seen Jul 2026
  • Format and Validate a Model ResponseONSITE INTERVIEW · Seen Apr 2026
  • Stateful Neuron Matrix UpdateONSITE INTERVIEW · Seen Apr 2026
  • Clock Hand Angle with Subsecond PrecisionONSITE INTERVIEW · Seen Dec 2025
  • Four-Player Matching Card GameONSITE INTERVIEW · Seen Feb 2025
  • Rotate an Array to the RightONSITE INTERVIEW · Seen Oct 2024
  • Rich-Text Segment Normalization and Bold ToggleONSITE INTERVIEW · Seen Apr 2024
  • Minimum Distance Matching in a ForestPHONE SCREEN · ONSITE INTERVIEW · Seen Feb 2024
  • Shortest Distance Between Two NodesONSITE INTERVIEW · Seen Jan 2024
  • Fit Beta Parameters by Maximum LikelihoodONSITE INTERVIEW · Seen Sep 2022

Similar questions at other companies

  • Find All Zip Rummy MeldsZip · PHONE SCREEN · ONSITE INTERVIEWZip interview questions
  • Fixed-Range Frequency CountWaymo · PHONE SCREENWaymo interview questions
  • Cheating CodemakerJane Street · OAJane Street interview questions
  • Random Dasher Set OperationsDoorDash · ONSITE INTERVIEWDoorDash interview questions
  • Logger Rate Limiter with Every-Arrival HistoryGoogle · PHONE SCREENGoogle interview questions
  • Propagating Fraud DetectorAffirm · PHONE SCREEN · ONSITE INTERVIEWAffirm interview questions
  • Order and Batch Open-Close LifecycleHudson River Trading · PHONE SCREENHudson River Trading interview questions
  • Pins Violation Log QueriesPinterest · PHONE SCREENPinterest interview questions
  • Deep Copy a Random-Pointer ListAmazon · ONSITE INTERVIEW
  • Apply Operations to Make a String EmptyFlexport · PHONE SCREENFlexport interview questions

Interview reports that mention this question

  • Scale AI SWE Intern Debugging Interview: 9 Experiences
  • Scale AI New Grad SWE and MLE Question Bank
  • Scale AI New Grad SWE Poker Screen and Onsite: 1 Experience

Scale AI interview experiences

  • Scale AI OA: What It Tests (2026)
  • Scale AI Forward Deployed Engineer Debugging Round: 1 Experience
  • Scale AI ML Research Engineering Intern Interviews: 1 Experience
All Scale AI interview questionsSee Scale AI hiring insights
Saved
class Solution {
    public String bestPokerCategory(String[] cards) {
        // Write your solution here
    }
}
Checking account…