✅Two Java Simple Solution || ✅Runtime 0ms || ✅ Beats100%
Intuition\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 
# Intuition\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:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code1\n```\nclass Solution {\n    public int getWinner(int[] arr, int k) {\n        int current = arr[0]; // Initialize with the first element\n        int count = 0;\n\n        for (int i = 1; i < arr.length ; i++) {\n            if (current > arr[i]) {\n                count++;\n            } else {\n                current = arr[i];\n                count = 1;\n            }\n            \n            if (count == k) return current;           \n        }\n        return current;\n    }\n}\n```\n\n# Code2\nThis solution is correct, but it consumes a lot of performance, so it gives **Time Limit Exceeded**\n```Java\nimport java.util.Hashtable;\nclass Solution {\n    public int getWinner(int[] arr, int k) {\n        Hashtable<Integer , Integer> hashtable = new Hashtable<>();\n        int count = 0;\n        while (count != k && count != arr.length-1 )\n        {\n            movesNumbers(arr , (arr[0] > arr[1])? 1 : 0 );\n            hashtable.put(arr[0] , hashtable.getOrDefault(arr[0] , 0 ) +1);\n            count = hashtable.get(arr[0]);\n        }\n       return arr[0];\n    }\n\n    public static void movesNumbers(int[] arr , int index)\n    {\n        int temp = arr[index];\n        for ( ; index < arr.length-1; index++) {\n           arr[index] = arr[index+1];\n        }\n        arr[index] = temp;\n    }\n}\n```\n\n## For additional problem-solving solutions, you can explore my repository on GitHub: [GitHub Repository](https://github.com/ahmedna126/java_leetcode_challenges)\n\n![abcd1.jpeg](https://assets.leetcode.com/users/images/f20c9c35-b365-47b4-b82a-047a3154c9d4_1699188527.9333048.jpeg)\n
['Java']