Issue with bali pair code

while my logic is same as the one given in the hint video, my submission is showing wrong answer while all the sample test cases are giving correct answer. I need help with debuging the code