Poker Hand Evaluator with Hidden Cards
Implement a card hand comparison system for a simplified poker game where each player holds up to 4 cards, supporting standard hand rankings (high card through four of a kind) with tie-breaking by card position. Extend the solution to handle variable-length hands containing hidden wildcard cards ('?'), determining if a winner can be guaranteed regardless of what the hidden cards reveal.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Early July, 2026
Part 1: Compare Two Hands Setup: Two players each hold a 4-card hand represented as a string (e.g., `"5233"`). Values: Digits `1` (lowest) to `9` (highest). Hand Rankings (Strongest to Weakest): | Rank | Hand Type | Example | | --- | --- | --- | | 5 | Four of a Kind | `"9999"` | | 4 | Two Pair | `"2332"` | | 3 | Three of a Kind | `"9998"` | | 2 | One Pair | `"5233"` | | 1 | High Card | `"2345"` | Comparison Rules: 1. The highest-ranked hand type wins. 2. If hand types tie, compare cards right-to-left (do not sort). The first higher-valued card wins. 3. If all cards match exactly, it is a tie. Task: Implement string evaluate(string hand1, string hand2); Returns: "HAND_1", "HAND_2", or "TIE". Constraints: Time complexity must be linear. Goal: Design your solution so that adding future hand types requires minimal code changes. --- Part 2: Variable Sizes & Hidden Cards Evolved Rules: Hands can now have any length (N >= 1 && N<=4). Hands may contain hidden cards represented by '?', which can take any value from 1 to 9 (e.g., "99??" vs "8877"). Task: Determine if the winner is already guaranteed, regardless of what the hidden cards turn out to be. Returns: "HAND_1", "HAND_2", "TIE", or "UNKNOWN".
Early July, 2026
Mid June, 2026
Hello Interview Premium
Your account is free and you can post anonymously if you choose.