Get Score Difference

Problem Overview

  • Two players alternately pick a positive integer from an array, add it to their score, and remove it; both play optimally.
  • Compute the absolute difference between Player 1 and Player 2 scores when the array is empty.
  • Input: points[n]; Output: long integer difference; Constraints: 1 <= n <= 1e5, 1 <= points[i] <= 1e9.
  • Set in Amazon Games; asked in Amazon interviews; a common coding interview problem and interview question.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: