Last Robot Score
Updated
Problem statement
Robots compete by score. While at least two robots remain, take the two robots with the highest scores and make them compete. If their scores are equal, both robots are eliminated. Otherwise, the robot with the larger score remains with its score reduced by the smaller score.
Return the score of the last remaining robot, or 0 if no robots remain.
Function
lastRobotScore(scores: int[]) → intExamples
Example 1
scores = [10,4,7,3]return = 210 and 7 leave 3, then 4 and 3 leave 1, then 3 and 1 leave 2. The last remaining robot has score 2.
Example 2
scores = [8,5,3]return = 08 and 5 leave 3, then the two 3s cancel.
Constraints
- The competition always uses the two currently highest scores.
More NVIDIA Phone Screen questions
- Network Layer Execution OrderPHONE SCREEN · Seen Nov 2026
- Paged KV Cache AccessPHONE SCREEN · Seen Nov 2026
- Sliding Window Attention over a KV CachePHONE SCREEN · Seen Nov 2026
- Summarize Server Healthcheck LogsPHONE SCREEN · Seen Oct 2026
- Hash Partition OffsetsPHONE SCREEN · Seen Oct 2026
- Filter Paginated Medical RecordsPHONE SCREEN · Seen Oct 2026
- Least Frequently Used CachePHONE SCREEN · Seen Oct 2026
- Parallel String Counts with a Custom Hash TablePHONE SCREEN · Seen Oct 2026
- Simulate a Reference-Counted Smart PointerPHONE SCREEN · Seen Aug 2026
- Streaming Top-K Frequent ElementsPHONE SCREEN · Seen Aug 2026
Similar questions at other companies
- ID Allocator with Assign and ReleaseSnap Inc. · PHONE SCREENSnap Inc. interview questions
- Allocate and Reuse Server Names by TypeStripe · PHONE SCREENStripe interview questions
- Bank Accounts with Transfers and a Richest LookupRippling · PHONE SCREENRippling interview questions
- Price-Time Order MatchingTwo Sigma · PHONE SCREENTwo Sigma interview questions
- Alert Engine with a Repeat IntervalChronosphere · PHONE SCREEN
- Finish Time of Fixed-Length CPU TasksGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
- Timer Job Scheduler Wake-upsRedNote · PHONE SCREEN
- Shortest-Job-First Process SchedulingByteDance · PHONE SCREENByteDance interview questions
- Key-Value Store on a Block DeviceLambda · PHONE SCREEN
- 15-Minute Chat Session TrackerOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions