WA in CHEFPSA

I got the approach from day one for CHEFPSA problem but still not able to pass all the test cases after going through various implementations.
can anyone help me to figure out where exactly is my code failing???

code

1 Like

@codersanjeev
Your code is not outputing the correct result if all the inputed numners of the array are negative.For ex;- -3,-5,-5,-7,-10…
Also this code will not output the correct result if the inputed array is all zero.
say for ex:- 0 0 0 0 0 0

1 Like
2
3
-3 -5 -5 -7 -10 -10
3
0 0 0 0 0 0

what is the expected output for this test case? @darkshadow2708

4
1

1 Like

its working for -ve numbers but for zeros, I fixed it and still it is getting WA in some TCs : (
new_code

Have a look at line 116 if(xx.first.first != xx.first.second){, I don’t think that is necessary.

1 Like

because it will not be able form pair of those numbers in any possible way, that’s why exit right there and print answer as 0.

thanks, it helped in passing some test cases, but it is still failing on the last 5 cases.
don’t know, what I was thinking while writing that if condition :man_facepalming:

code