🔥 Beats 100% | Simplest Solution 🚀🚀 | C++ | Java | Python | Javascript
Intuition\n\n\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- T
# Intuition\n![Screenshot 2023-11-05 111941.png](https://assets.leetcode.com/users/images/7e9682c5-a6ea-4ae4-a549-6de6e823ef1d_1699163518.4750323.png)\n\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int getWinner(vector<int>& arr, int k) {\n        ios_base::sync_with_stdio(false);\n        cin.tie(0);\n        cout.tie(0);\n        \n        int n = arr.size();\n        // Assume first element as our answer\n        int ans = arr[0];\n        int win = 0;\n\n        for(int i = 1; i < n; i++)\n        {\n            // if current element > answer\n            // Update answer\n            if(arr[i] > ans)\n            {\n                ans = arr[i];\n                win = 0;\n            }\n\n            win++;\n\n            if(win == k)\n                break;\n        }\n\n        return ans;\n    }\n};\n```
['Array', 'C', 'Simulation', 'Python', 'C++', 'Java', 'JavaScript']