← 返回 rippling 的题目列表Compare Two Poker-like Hands with Custom Ranking Rules
类型:online_judge
Problem: Compare Two Poker-like Hands with Custom Ranking Rules
You are given a set of hand-ranking comparison rules (provided by the interviewer). The rules define which hand categories are stronger and how to break ties within the same category.
Given two players' hands, determine which player wins.
Input
Two string arrays hand1 and hand2
Each array represents a player's hand (each element is a card string; exact encoding is defined in the prompt).
Output
Return "user1" or "user2" to indicate whose hand is stronger.
If ties are possible, handle them according to the prompt (or clarify expected output such as "tie").
Requirements/Constraints
Follow the provided rules exactly.
The interview emphasized:
Avoid a large chain of if/else checks for all rules.
Prefer an extensible abstraction (e.g., Strategy Pattern / pluggable rule evaluators).
Example (placeholder)
The original post does not include the exact rules or card encoding, so examples depend on the interviewer's specification.
Example
Input
(depends on provided rules/encoding)
Output
user1