Adjacent Equal-Pair Removal Game
Updated
Problem statement
Alice and Bob play a game on a string values. Alice moves first. On each move, remove any adjacent equal pair; the remaining characters close together.
A player who cannot move loses. Return "Alice" or "Bob" assuming optimal play.
Function
pairRemovalWinner(values: String) → StringExamples
Example 1
values = "aa"return = "Alice"Alice removes the only pair, leaving Bob without a move.
Example 2
values = "abba"return = "Bob"Two cancellations occur, so Bob makes the final move.
Constraints
0 <= values.length <= 100000valuescontains lowercase English letters.
More ZipRecruiter Online Assessment questions
- Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
- Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
- Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
- Minimum Changes to Draw a YOA · Seen Oct 2024
- Apply Binary State OperationsOA · Seen Sep 2024
- Simulate Orchard Rot SpreadOA · Seen Sep 2024
- Compare Odd- and Even-Index SumsOA · Seen Sep 2024
- Coordinate Removals with Column GravityOA · Seen Sep 2024
- Lexicographically Smallest End ReversalOA · Seen Sep 2024
- Recursively Expanded Shell Command CountsOA · Seen Sep 2024
Similar questions at other companies
- Smallest Value for a Linear Expression ModuloIntel · OA
- Calculate a Token-List ExpressionCollege Vine · ONSITE INTERVIEW
- Basic Calculator IISnap Inc. · PHONE SCREENSnap Inc. interview questions
- Basic Calculator II With Empty InputGoogle · ONSITE INTERVIEWGoogle interview questions
- Evaluate Arithmetic with Operator PrecedenceRoblox · PHONE SCREENRoblox interview questions
- Simplify a Formula with Known and Unknown VariablesBetter.com · PHONE SCREEN
- Evaluate Parenthesized Addition and SubtractionAtlassian · PHONE SCREENAtlassian interview questions
- Stack Formula InterpreterTypeSafe AI · PHONE SCREEN
- Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW
- Perfect Squares Matching a PatternNielsen · OA