Test cases failing

Hi,

Please find the below code for finding Closest To Origin points. The code is getting accepted on leetcode. But I am getting a run error in one of the test case and other test case is failing. Help me identify root cause for the same.

@PThak2018 try this test
4
3 3
5 -1
-2 4
0 0
2
answer should be
0 0
3 3
but your answer is
3 3
0 0

The test case provided in the question doesn’t give the answer in sorted order.
But as suggested, I am printing the answer now in sorted order but again I am getting wrong answer and run error. Could you please check the test cases, there may be some problem in it.

You can refer to updated code used to print in sorted order.

@PThak2018
for this test
4
0 1
0 2
-2 4
2 0
2
output should be
0 1
0 2
(as 0 2 appears before 2 0)
note that you also have to maintain relative order in case of distance tie!
Well for run error, I don’t see any cause as you are not accessing any out of bounds or empty stack/heap!

Tried this as well. Although it should not give error on the order basis, but still after reordering getting same results.
Can you check the test cases used for this question . There might be some problem with it.

Okay , I’ll get back to you after confirmation.

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.