Simple HashMap,Simulation Solution Java
Java Code\n---\n\nclass Solution {\n    public int getWinner(int[] arr, int k) {\n        LinkedList<Integer> ll = new LinkedList<>();\n        int maxEle = Int
# Java Code\n---\n```\nclass Solution {\n    public int getWinner(int[] arr, int k) {\n        LinkedList<Integer> ll = new LinkedList<>();\n        int maxEle = Integer.MIN_VALUE;\n        for(int item : arr)\n        {\n            ll.add(item);\n            maxEle = Math.max(maxEle,item);\n        }\n        if(k>=arr.length)\n            return maxEle;\n        HashMap<Integer,Integer> hmap = new HashMap<>();\n        int winner = -1;\n        while(true)\n        {\n            if(ll.get(0) > ll.get(1))\n            {\n                winner = ll.get(0);\n                if(hmap.containsKey(winner))\n                    hmap.put(winner,hmap.get(winner)+1);\n                else\n                {\n                    hmap.clear();\n                    hmap.put(winner,1);\n                }\n                ll.add(ll.remove(1));\n            }\n            else\n            {\n                winner = ll.get(1);\n                if(hmap.containsKey(winner))\n                    hmap.put(winner,hmap.get(winner)+1);\n                else\n                {\n                    hmap.clear();\n                    hmap.put(winner,1);\n                }\n                ll.add(ll.remove(0));\n            }\n            if(hmap.get(winner) == k)\n                break;\n        }\n        return winner;\n    }\n}\n```\n---
['Array', 'Simulation', 'Java']