Strongest Fighter

I assume that we need to solve it as finding the max element in the group of k elements. Let me know if there is any issue with the code.

@aroraswati859 Can you specifically tell me your issue.

Hi Piyush, I have used dequeue approach only but Im getting all test cases failing

Please can you check the code. I suppose there is some issue how we need to output the result. Logic seems to be fine. I ran with sample input also.

@aroraswati859 A little mistake in the very first loop of the printMax function inside while loop you have used

if(!q.isEmpty() && arr[i] > arr[q.getLast()]){
                q.removeLast();
            }

Instead of ‘if’ you have to use a while loop like this. :

while(!q.isEmpty() && arr[i] > arr[q.getLast()]){
                q.removeLast();
            }
``` Everything is fine.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.