what’s wrong with my code
Review my code to get it right
sorry earlier was wrong this is correct according to me
Okay I’ll debug it for you, till then be patient
hey @singh.pankhil40 you got the implementation right, but there are few mistakes which you haven’t considered , like side case in your compare function and in for loop of line number 20. Here’s the code which I have designed for you and have also added few comments in it. Try to find your mistake and implement it in your code as you can see your mistake in the following test case:
Input:
5
1 1
2 1
3 1
4 1
6 1
Expected Output is : 2
Your Output is : 3
Correct code:
can you tell me why you have modified compare function
You forgot to check what if c+r is same for two pairs, in that case we will do p1.first < p2.first that means ascending order.