Strongest Fighter

I am getting wrong answer in 3 test case, kindly suggest corrections in my code:

Hey @Puneet_Sharma
you are doing wrong
try for this input
6
1 3 1 2 0 5
3
correct output : 3 3 2 5
your code gives 3 3 1 5
Use Deque Instead of Queue

  1. Create a deque to store k elements.
  2. Run a loop and insert first k elements in the deque. While inserting the element if the element at the back of the queue is smaller than the current element remove all those elements and then insert the element.
  3. Now, run a loop from k to end of the array.
  4. Print the front element of the array
  5. Remove the element from the front of the queue if they are out of the current window.
  6. Insert the next element in the deque. While inserting the element if the element at the back of the queue is smaller than the current element remove all those elements and then insert the element.
  7. Print the maximum element of the last window.
    you can see this
    correct code :
    https://ide.codingblocks.com/s/290982