Easy O(1) space solution
Code\ncpp []\nclass Solution {\npublic:\n    int getWinner(vector<int>& a, int k) {\n        int n=a.size();\n        int mx=a[0],cnt=0;\n        for(int i=1;i<
# Code\n```cpp []\nclass Solution {\npublic:\n    int getWinner(vector<int>& a, int k) {\n        int n=a.size();\n        int mx=a[0],cnt=0;\n        for(int i=1;i<n;i++){\n            if(mx>a[i]) cnt++;\n            else{\n                mx=a[i];\n                cnt=1;\n            }\n            if(cnt==k) return mx;\n        }\n        return *max_element(a.begin(),a.end());\n    }\n};\n```
['C++']