Easy Two Pointer Approach O(1) space
Intuition\n Describe your first thoughts on how to solve this problem. \n# Approach\n Describe your approach to solving the problem. \nCheck arr[0] with every e
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n# Approach\n<!-- Describe your approach to solving the problem. -->\nCheck arr[0] with every element using a loop, and follow below conditions:\n1. if arr[0] is greater than arr[i] then increase win_count\n2. else swap(arr[0],arr[i]) and make win_count = 1\n3. Break loop if win_count==k or when loop ended and return arr[0]\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n**O(n)**\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n**O(1)**\n# Code\n```\nclass Solution {\npublic:\n    int getWinner(vector<int>& arr, int k) {\n        int win_count = 0;\n        for(int i=1;i<arr.size();i++){\n            if(arr[0]>arr[i]){\n                win_count++;\n            }\n            else{\n                swap(arr[0],arr[i]);\n                win_count = 1;\n            }\n            if(win_count==k) return arr[0];\n        }\n        return arr[0];\n    }\n};\n```
['C++']