Best Poker Category with a Joker
Updated
Problem statement
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_KINDSTRAIGHT_FLUSHFOUR_OF_A_KINDFULL_HOUSEFLUSHSTRAIGHTNONE
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[]) → StringExamples
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