FastPrepOptimal Score Difference in an Endpoint Game
Problems/Optimal Score Difference in an Endpoint Game

Optimal Score Difference in an Endpoint Game

Rippling logoRippling● MediumINTERNFULLTIMEOA

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The endpoint game and score-difference objective match the source at about 95%. Optimal play and numeric bounds are explicit practice rules.

Two players alternately remove either the first or the last number from nums until the array is empty. A removed number is added to that player's score. The first player moves first.

Both players play optimally to maximize their own final score. Return the first player's score minus the second player's score. The answer may be negative.

Function

maximumScoreDifference(nums: int[]) → int

Examples

Example 1

nums = [1,5,2]return = -2

The first player can collect 3 while the second collects 5, giving -2.

Example 2

nums = [4,7,2,9]return = 10

The first player can secure 16 while the second collects 6, giving 10.

Constraints

  • 1 <= nums.length <= 1000.
  • -10^6 <= nums[i] <= 10^6.

More Rippling Online Assessment questions

  • Most Segments That Sort the ArrayOA · Seen Nov 2026
  • Palindromic Paths to the RootOA · Seen Nov 2026
  • Server InvestmentOA · Seen Nov 2026
  • Corporate Card Expense RulesOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • REST API: Highest International StudentsOA · Seen Sep 2026
  • Token ValidationOA · Seen Sep 2026
  • Consistent LogsOA · Seen Sep 2026
  • Costliest ChocolateOA · Seen Sep 2026
  • Server ManagementOA · Seen Sep 2026
  • Cyber Beacon DetectionOA · Seen Aug 2026

Similar questions at other companies

  • Card Game: Best First-Player ScoreShopify · OAShopify interview questions
  • Maximum Game Score with Fixed Forward JumpsStripe · OAStripe interview questions
  • 0/1 KnapsackConfluent · OAConfluent interview questions
  • Minimum Cost to Tile a Strip with Widths 1, 2, and 3Infosys · OAInfosys interview questions
  • Maximum Escape Game ScoreMicrosoft · OAMicrosoft interview questions
  • Maximum Subarray SumStraive · OA
  • Longest Increasing Price SubsequenceOpenAI · OAOpenAI interview questions
  • Lowest-Cost Shirt Color ScheduleElevenLabs · OAElevenLabs interview questions
  • Maximum Game Board ScoreJP Morgan Chase · OAJP Morgan Chase interview questions
  • API Bandwidth AllocationArista Networks · OAArista Networks interview questions

Interview reports that mention this question

  • Rippling Intern Interview History: 17 Experiences (Part 5 of 5)

Rippling interview experiences

  • Rippling Senior SWE Full Loop Questions: 1 Experience
  • Rippling Experienced SWE Phone Screens: 2 Experiences
  • Rippling Design Rounds and Onsites: 17 Experiences (Part 3 of 3)
  • Rippling Phone Coding Screens: 14 Experiences (Part 2 of 3)
  • Rippling SWE Screens and Loops: 31 Experiences (Part 1 of 3)
All Rippling interview questionsSee Rippling hiring insights
Saved
class Solution {
    public int maximumScoreDifference(int[] nums) {
        // write your code here
    }
}
Checking account…