As reported: Goldman Sachs Associate HackerRank OA (3 DSA questions in 135 minutes, 2026): LeetCode 1535.
Given an array of distinct integers arr and k, a game compares arr[0] and arr[1] each round; the larger stays at the front, the smaller moves to the end. The first integer to win k consecutive rounds wins. Return it.
This is LeetCode 1535 — Find the Winner of an Array Game.
Example 1
arr = [2,1,3,5,4,6,7], k = 2
-> 5
Example 2
arr = [3,2,1], k = 10
-> 3
Constraints: 2 ≤ arr.length ≤ 10^5; 1 ≤ arr[i] ≤ 10^6, distinct; 1 ≤ k ≤ 10^9.
Code runner format: one JSON value per line: arr, then k (LeetCode's test-case format). Implement getWinner(arr, k); the harness prints the result as JSON.