Java | one pass and constant space
edge case: k >= n\nwin k times is equivalent to bigger than k numbers in arr\n\n    public static int getWinner(int[] arr, int k) {\n        int n = arr.length;
edge case: k >= n\nwin k times is equivalent to bigger than k numbers in arr\n```\n    public static int getWinner(int[] arr, int k) {\n        int n = arr.length;\n\n        int curFirst = arr[0], curCount = 0;\n        for (int i = 1; i < n; i++) {\n            if (arr[i] < curFirst) {\n                if (++curCount == k) return curFirst;\n            } else {\n                curFirst = arr[i];\n                curCount = 1;\n                // hande k = 1 case\n                if (curCount == k) return curFirst;\n            }\n        }\n        //curFirst is max(arr[i]), no need to test k - curCount times\n        return curFirst;\n    }\n\t\n```
['Java']