【C++】O(N) straightforward solution
\nclass Solution {\npublic:\n    int getWinner(vector<int>& arr, int k) {\n        if(k >= arr.size() - 1) return *max_element(arr.begin(), arr.end());\n       
```\nclass Solution {\npublic:\n    int getWinner(vector<int>& arr, int k) {\n        if(k >= arr.size() - 1) return *max_element(arr.begin(), arr.end());\n        int cur = arr[0], cnt = 0;\n        for(int i = 1; i < arr.size(); ++i) {\n            int n = arr[i];\n            if(cur > n) {\n                if(++cnt >= k) return cur;\n                arr.push_back(n);\n            }else {\n                if((cnt = 1) >= k) return n;\n                arr.push_back(cur);\n                cur = n;\n            }\n        }\n        return arr.back();\n    }\n};\n```
[]