Stone Game III
Updated
Problem statement
Alice and Bob play a game using the integer array stoneValue. Alice moves first. On each turn, a player removes the first 1, 2, or 3 remaining stones and adds their values to that player's score. Play continues until no stones remain.
Both players choose moves that maximize their own final score. Return "Alice" if Alice's score is greater, "Bob" if Bob's score is greater, or "Tie" if the scores are equal.
Function
stoneGameIII(stoneValue: int[]) → StringExamples
Example 1
stoneValue = [1,2,3,7]return = "Bob"No matter whether Alice takes one, two, or three stones, Bob can take the remaining high-value group and finish with the larger score.
Example 2
stoneValue = [1,2,3,-9]return = "Alice"Alice can take the first three stones for 6, leaving -9 for Bob.
Example 3
stoneValue = [1,2,3,6]return = "Tie"With optimal play, Alice takes the first three stones for 6 and Bob takes the final stone worth 6.
Constraints
1 <= stoneValue.length <= 50000.-1000 <= stoneValue[i] <= 1000.
More Google Phone Screen questions
- Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Periodic-Color Binary Forest RootsPHONE SCREEN · Seen Nov 2026
- Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
- Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
- Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
- Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
- Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- Coin Game From The EndsTekion · PHONE SCREENTekion interview questions
- Maximum-Product Subarray with an Empty ChoiceAkuna Capital · PHONE SCREENAkuna Capital interview questions
- At Most K Jumps with Quadratic Transition CostInfosys · OAInfosys interview questions
- Jump Game with Prime-3 StepsUber · OAUber interview questions
- Maximum Score with Prime JumpsMicrosoft · OAMicrosoft interview questions
- Jump Game with Prime-3 StepsAgoda · OAAgoda interview questions
- Pascal's TriangleJP Morgan Chase · ONSITE INTERVIEWJP Morgan Chase interview questions
- Tree Path GCDNewton School · PHONE SCREEN
- Split Array to Minimize the Largest SumNation with NaMo · PHONE SCREEN
- Trapping Rain WaterOracle · PHONE SCREENOracle interview questions