Code giving error on leetcode

Hey, this is the link to this question on leetcode :

and this is the link to my submission for this code :
https://ide.codingblocks.com/s/210752

this is giving a runtime error for the case : [1,-1] , k = 1.
please help me in identifying the problem in my code

@alankrit.agr99
hello Alankrit,
image

here first check whether ur dq is empty or not . if not then only perform pop operation or comparision

1 Like

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.