FastPrepFind the Winner of an Array Game
Problems/Find the Winner of an Array Game

Find the Winner of an Array Game

Goldman Sachs logoGoldman Sachs● MediumFULLTIMEOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A Goldman Sachs HackerRank assessment report links the exact Find the Winner of an Array Game exercise and says the test cases matched. This practice version is an approximately 99% match.

Distinct integers in arr play repeated rounds. Compare the first two values: the larger remains at the front, and the smaller moves to the end. The round winner's consecutive-win count increases; a different winner starts a new streak at one.

Return the first value to win k consecutive rounds.

Function

arrayGameWinner(arr: int[], k: int) → int

Examples

Example 1

arr = [2,1,3,5,4,6,7]k = 2return = 5

Five defeats 3 and 4 in consecutive rounds.

Example 2

arr = [3,2,1]k = 10return = 3

Once the maximum reaches the front it can never lose.

Constraints

  • 2 <= arr.length <= 100000
  • 1 <= k <= 10^9
  • Values are distinct signed 32-bit integers.

More Goldman Sachs Online Assessment questions

  • Maximum Ones After K OperationsOA · Seen Nov 2026
  • Palindrome CounterOA · Seen Oct 2026
  • Longest Palindromic SubsequenceOA · Seen Oct 2026
  • Count Redundant File BackupsOA · Seen Oct 2026
  • Minimum Distinct Prefix CostOA · Seen Oct 2026
  • Merge Overlapping IntervalsOA · Seen Sep 2026
  • Data ReorganizationOA · Seen Jul 2026
  • Alternating Parity PermutationsOA · Seen Jul 2026
  • Threshold AlertsOA · Seen Jul 2026
  • Minimum Number of Taps to Water a GardenOA · Seen Jun 2026

Similar questions at other companies

  • Payment Partner RoutingStripe · OAStripe interview questions
  • Bank Accounts with Balance HistoryMeta · OAMeta interview questions
  • Capping Portfolio WeightsCapstone Investment Advisors · OA
  • Repeated Mirror XORMathWorks · OAMathWorks interview questions
  • Stacked Item and Category DiscountsPalantir · OAPalantir interview questions
  • Stabilize Student Test ScoresVirtu Financial · OAVirtu Financial interview questions
  • Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Minimize Task Resource ConsumptionNVIDIA · OANVIDIA interview questions
  • Index of the Maximum After Left RotationsChubb · OAChubb interview questions
  • Leaves Remaining After WindCresta · OACresta interview questions
All Goldman Sachs interview questionsSee Goldman Sachs hiring insights
Saved
class Solution {
    public int arrayGameWinner(int[] arr, int k) {
      // write your code here
    }
}
Checking account…