EASY DEQUE SOLUTION IN C++
\n                    \u0950 \u0924\u094D\u0930\u094D\u092F\u092E\u094D\u092C\u0915\u0902 \u092F\u091C\u093E\u092E\u0939\u0947 \u0938\u0941\u0917\u0928\u094D\u0
\n                    \u0950 \u0924\u094D\u0930\u094D\u092F\u092E\u094D\u092C\u0915\u0902 \u092F\u091C\u093E\u092E\u0939\u0947 \u0938\u0941\u0917\u0928\u094D\u0927\u093F\u0902 \u092A\u0941\u0937\u094D\u091F\u093F\u0935\u0930\u094D\u0927\u0928\u092E\u094D |\n                    \u0909\u0930\u094D\u0935\u093E\u0930\u0941\u0915\u092E\u093F\u0935 \u092C\u0928\u094D\u0927\u0928\u093E\u0928\u094D\u092E\u0943\u0924\u094D\u092F\u094B\u0930\u094D\u092E\u0941\u0915\u094D\u0937\u0940\u092F \u092E\u093E\u093D\u092E\u0943\u0924\u093E\u0924\u094D ||\n\n\n# Intuition\nThis problem can be solved by using a deque , so that we can push the minimum element to the back of deque and maximum element to the front of deque \n\n# Approach\n- First create a deque `deque<int>Q(arr.begin(),arr.end())`\n  This copies all the elements of `arr` to the deque in same order \n- Initialize `Winner` with least possible number `INT_MIN` , and    `count` to `0`\n- Our loop should run till the size of `arr` in worst case or else we can break out of the loop if `count` is same as `k`\n- After initializing `max` and `min` , `max` element should stay at `0` index , and `min` at  `n-1` i.e last index \n- So Pop out first two elements by using `pop_front()` twice and push `min` to back of deque ,and max to front of deque \n- Now check if `Winner` and `max` are same , if so increment the `count` by 1 else we know that previously initialized `winner` is changed , so we equate it to current `max` element and reset the `count` back to 1 \n- Once the loop ends return the element which is at the `front` of the deque\n\n# Complexity\n- **Time complexity**:\n    Average : $$O(k*n) $$ \n    Worst Case : $$O(k^2)$$\n\n- **Space complexity**:\n    $$O(n)$$ -> Size of Deque \n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Please Upvote the solution :)\n\n# Code\n```\nclass Solution {\npublic:\n    int getWinner(vector<int>& arr, int k) {\n        deque<int> Q(arr.begin(),arr.end());\n        int Winner = INT_MIN;\n        int count = 0 ;\n        int n= arr.size();\n        for(int i= 0 ; i<n && count!=k ;i++){\n            int max = (Q[0]>Q[1])?Q[0]:Q[1];\n            int min = (Q[0]>Q[1])?Q[1]:Q[0];\n            Q.pop_front();\n            Q.pop_front();\n            Q.push_back(min);\n            Q.push_front(max);\n            if(Winner==max && count!=k){\n                count++;\n            }else{\n                count= 1;\n                Winner = max;\n            }\n        }\n        if(!Q.empty()){\n            return Q.front() ;\n        }\n        return 0 ;\n        \n    }\n};\n```
['C++']