FastPrepScore Difference When Even Picks Reverse the List
Problems/Score Difference When Even Picks Reverse the List

Score Difference When Even Picks Reverse the List

Microsoft logoMicrosoft● EasyINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A 2025 on-campus Microsoft internship online assessment included a two-player game question. Whenever a player's pick is even, the order of the remaining numbers flips. The task is to report how far apart the two scores end up. The candidate labeled it a greedy problem.

The report leaves several rules open, so these are our choices. Each player always takes the number at the front of the current list. A player's score is the sum of the numbers they took. 0 counts as even, so taking it also flips the rest. The answer is the first player's score minus the second player's. The report also gives no examples or limits. This page uses up to 10^5 numbers, each from 0 to 10^4.

Our version is about 70% the same as the reported question.

Alice and Bob play a game with a list of numbers nums. Alice moves first, and then they take turns until the list is empty.

On each turn, the current player removes the first number of the current list and adds it to their own score. If that number is even, the rest of the list is reversed before the next turn. If it is odd, the rest of the list stays as it is. Note that 0 is even.

Both scores start at 0. Return Alice's final score minus Bob's final score.

Function

scoreDifference(nums: int[]) → int

Examples

Example 1

nums = [3,4,1,6,5]return = -1

Alice takes 3 (odd, nothing changes). Bob takes 4, which is even, so the rest [1, 6, 5] becomes [5, 6, 1]. Alice takes 5. Bob takes 6, which is even, so the rest [1] is reversed and stays [1]. Alice takes 1.

Alice has 3 + 5 + 1 = 9 and Bob has 4 + 6 = 10, so the answer is 9 - 10 = -1.

Example 2

nums = [2,7,9,1]return = 3

Alice takes 2, which is even, so [7, 9, 1] becomes [1, 9, 7]. Bob takes 1. Alice takes 9. Bob takes 7.

Alice has 2 + 9 = 11 and Bob has 1 + 7 = 8, so the answer is 3.

Example 3

nums = [5]return = 5

Alice takes the only number, 5. Bob takes nothing, so the answer is 5 - 0 = 5.

Constraints

  • 1 <= nums.length <= 10^5
  • 0 <= nums[i] <= 10^4

More Microsoft Online Assessment questions

  • Minimum Cost to Process Priority TasksOA · Seen Nov 2026
  • Most Visited Sprint MarkerOA · Seen Nov 2026
  • Maximum Escape Game ScoreOA · Seen Nov 2026
  • Count Subarrays with a Perfect-Square ProductOA · Seen Nov 2026
  • Maximum Interactive Team SizeOA · Seen Nov 2026
  • Maximize Pipeline Throughput Under a Scaling BudgetOA · Seen Nov 2026
  • Minimum Cost K-Capable ModelsOA · Seen Nov 2026
  • Find Available Meeting RoomsOA · Seen Oct 2026
  • Maximum Sum of a K-StarOA · Seen Oct 2026
  • Capacity to Ship Packages Within DaysOA · ONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Collect Branches for a Bird NestVisa · OAVisa interview questions
  • Match OutcomesAdobe · OAAdobe interview questions
  • Rotate the Box and Drop the StonesZipRecruiter · OAZipRecruiter interview questions
  • Configuration SystemPostman · OAPostman interview questions
  • Alternate Positive and Negative ValuesTesla · ONSITE INTERVIEWTesla interview questions
  • Merge a 2048 RowPalantir · PHONE SCREENPalantir interview questions
  • Candy Crush Grid Matching and GravityRoblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions
  • Add Signed Character ArraysByteDance · PHONE SCREENByteDance interview questions
  • Nested List Iterator with RemoveAirbnb · PHONE SCREENAirbnb interview questions

Interview reports that mention this question

  • Microsoft SWE Intern, Early 2025: 41 Experiences (Part 5 of 6)
  • Microsoft SWE Intern Interviews: 244 Experiences (Part 1 of 6)

Microsoft interview experiences

  • Microsoft Explore and Student SWE: 12 Experiences (Part 6 of 6)
  • Microsoft SWE Intern, Mid 2025: 42 Experiences (Part 4 of 6)
  • Microsoft SWE Intern, Late 2025: 47 Experiences (Part 3 of 6)
  • Microsoft SWE Intern, Early 2026: 54 Experiences (Part 2 of 6)
All Microsoft interview questionsSee Microsoft hiring insights
Saved
class Solution {
    public int scoreDifference(int[] nums) {
        // Write your code here.
    }
}
Checking account…