✅|Understand the question|Explain|0ms|beats100%
Approach\nSuper Easy Question Just Understand that Either First Integer is Wining or Second Integer is wining from Array, so just compare the largest number upt
# Approach\nSuper Easy Question Just Understand that Either First Integer is Wining or Second Integer is wining from Array, so just compare the largest number upto i<sup>th</sup> with arr[i-k] && arr[i-k+1] if largest is equal to any of them then matched value will be the answer BOOM!!!!\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```java []\nclass Solution {\n    public int getWinner(int[] arr, int k) {\n        int lar = 0;\n        for(int i = 0; i < k && i < arr.length; i++)\n        {\n            lar = Math.max(arr[i] , lar);\n        }\n        for(int i = k; i < arr.length; i++)\n        {\n            lar = Math.max(lar,arr[i]);\n            if(lar == arr[i-k] || lar == arr[i-k+1])\n                return lar;\n        }\n        return lar;\n    }\n}\n```\n```C++ []\nclass Solution {\npublic:\n    int getWinner(vector<int>& arr, int k) {\n        int lar =0;\n        for(int i = 0; i < k && i < arr.size() ; i++)\n        {\n            lar = max(lar,arr[i]);\n        }\n        for(int i = k; i < arr.size(); i++)\n        {\n            lar = max(lar,arr[i]);\n            if(lar == arr[i-k] || lar == arr[i-k+1])\n                return lar;\n        }\n        return lar;\n    }\n};\n```
['Array', 'Sliding Window', 'Simulation', 'C++', 'Java']