What is wrong in the code it is failing one testcase?

@ayush.18 this is what i am saying that there is no need to make stack of pair you can do this by only indexes .

@ayush.18 see this code i have modified your logic .


Happy Learning !!