Easy to Understand Simulation✌️ || O(1) space || Beats 85% ✅✅ || Beginner Friendly Solution
Intuition\nAfter one round of simulation, for next rounds number will be in increasing sorted order.\n\n# Approach\n- Simulate just once.\n- ex - 2 1 3 5 4 6 7 
# Intuition\nAfter one round of simulation, for next rounds number will be in increasing sorted order.\n\n# Approach\n- Simulate just once.\n- ex - 2 1 3 5 4 6 7 -> 2 3 5 4 6 7 1 -> 3 5 4 6 7 1 2 -> 5 4 6 7 1 2 3\n-> 5 6 7 1 2 3 4 -> 6 7 1 2 3 4 5 -> 7 1 2 3 4 5 6 -> ***1 2 3 4 5 6 7***\n\n- so now, answer will be the maximum number\n\n# Complexity\n- Time complexity: $$O(n)$$\n\n- Space complexity: $$O(1)$$\n\n# Code\n```\nclass Solution {\npublic:\n    int getWinner(vector<int>& arr, int k) {\n        int count = 0;\n        int maxa = arr[0]; // store current maximum out of two numbers\n        int ans = arr[0]; // stores maximum element of all elements in array\n        for(int i = 1;i<arr.size();i++)\n        {\n            ans = max(ans, arr[i]);\n            if(arr[i]<maxa) // if the previous maximum is still the maximum out of two\n                count++; //increase its number of wins\n            else\n            {\n                count = 1; // new winner\n                maxa = arr[i];\n            }\n            if(count==k) // if one of the element has won k times\n                return maxa;\n        }\n        return ans; // else return the maximum of all the elements\n    }\n};\n```
['Simulation', 'C++']