← 返回 rippling 的题目列表Compare two poker hands with possibly incomplete information (output UNKNOWN if winner cannot be determined)
类型:online_judge
Problem: Compare two poker hands with possibly incomplete information (output UNKNOWN if undecidable)
You are given two players' poker hands. Each hand represents known card ranks (duplicates allowed), but the input hand may be incomplete (i.e., some of the 5 final cards are unknown).
Determine the outcome based on the known information:
Output A if Player A must win regardless of how the missing cards are filled.
Output B if Player B must win regardless of how the missing cards are filled.
Output UNKNOWN if the winner cannot be determined uniquely (i.e., there exists a completion where A wins and another where B wins, or a tie/ambiguity is possible).
Note
Per the interview description, each hand is ultimately 5 cards.
The key twist is handling incomplete input. Example: known 9999 vs 9 is not enough to determine the winner, so output UNKNOWN.
Input (you may define exact parsing)
Two strings handA and handB, each containing 1 to 5 known ranks.
Rank range / whether suits matter: not specified; you may treat ranks only.
Output
Print one of: A, B, UNKNOWN.
Constraints
Final hand size is 5; input size is 1..5.
Sample Tests
A=9999, B=9 => UNKNOWN
A=23456, B=99999 => B
A=AAAAA, B=KKKKK => A
A=2222, B=3333 => UNKNOWN
A=7, B=8 => UNKNOWN
Example
Input
9999
9
Output
UNKNOWN