← 返回 sofi 的题目列表Rock-Paper-Scissors Lineup
类型:qbank
Array game prompt: process players' rock-paper-scissors hands from the front of the line and compute how many changes are needed for your hand to beat the current and remaining winners.
Requirements
Input is an array containing each person's rock-paper-scissors hand.
Start comparison from the first person and move forward.
If two players tie, both are eliminated.
Compute how many times your hand must change to beat the previous winner and then all later players.
A brute-force solution is acceptable for a first pass; the optimal solution appears to use a greedy observation.
Notes
The original statement was long and easy to misread in HackerRank.
Clarify who "you" are in the array, whether hand changes are counted before each match or only when necessary, and how consecutive ties affect the active winner.