using deque JAVA
Code

# Code
```java []
class Solution {
    public boolean populate(HashMap<Integer,Integer>num_win, int num, int k)
    {
        int wins=1;
        if(!num_win.containsKey(num))
        {
             wins=1;
                num_win.put(num,1);}
        else
        {
             wins= num_win.get(num)+1;
            num_win.put(num,wins);
           
        }
         if(wins==(k))
         {
            return true;
         }
         return false;
        
    }
    public int getWinner(int[] arr, int k) {
        
        // [2,1,3,5,4,6,7]
        // [2,3,5,4,6,7,1] 2-1
        // [3,5,4,6,7,1,2] 3-1
        // [5,4,6,7,1,2,3] 5-1
        // [5,6,7,1,2,3,4] 5-2 =return

        int n= arr.length;
        int win=0;
        HashMap<Integer,Integer>num_win=  new HashMap<>();
        Deque<Integer>dq= new LinkedList<>();
        int maxele= arr[0];
       
        for(int num:arr)
        {
            dq.add(num);
            maxele=Math.max(maxele, num);
        }
         if(k>= arr.length)
            return maxele;
        while(win!=k)
        {
            if(dq.getFirst()== maxele)
                return maxele;
            
            int first= dq.removeFirst();
            int sec= dq.removeFirst();

            boolean flag=false;
            if(first>sec)
            {
               flag= populate(num_win, first,k);
            if(flag)
                return  first; 
                dq.addFirst(first);
                dq.addLast(sec);
            }
            else
            {
               flag= populate(num_win, sec,k);
               if(flag)
                return  sec; 
                dq.addFirst(sec);
                dq.addLast(first);
            }

           

            
           
        }
        return -1;
        
    }
}
```
['Java']