100% O(n) Java solution with counter
We traverse the array once. We don\'t really have to worry about the integer appending to the back of the array part as I will explain later.\n\nThe intuition i
We traverse the array once. We don\'t really have to worry about the integer appending to the back of the array part as I will explain later.\n\nThe intuition is to try and find the number of times each local maximum would win. If the number of wins reach k, we found our answer.\n\nDuring the traversal if the next encountered element is smaller than our "max" we increment counter. Otherwise we reset counter to one (just this game that was just won), and update max. \n\nIf there\'s no such local maximum till the end of the traversal, we then return the whatever\'s in local maximum after array traversal, because it actually holds the absolute maximum integer of the array, and it will never lose a subsequent games from this point on. \n\n```\nclass Solution {\n    public int getWinner(int[] arr, int k) {\n        int max = Math.max(arr[0], arr[1]);\n        int count = 1;\n        for(int i = 2; i < arr.length; i++){\n            if(count >= k){\n                return max;\n            }\n            if(arr[i] > max){\n                count = 1;\n                max = arr[i];\n            }\n            else{\n                count++;\n            }\n        }\n        return max;\n    }\n}\n```
[]