Help needed in ScratchCode - CandyRush

Here is my solution to the problem. I am getting partial points. I have checked other submissions[1, 2] where there are printing sum of max no. of targets in a row and column.

But consider the case when targets in column and row coincide :
2 3 3
1 1
0 0
0 1

Both the codes print answer as 4, even if there are only 3 targets to destroy. Since there are 3 targets correct answer should be 3.
Does the problem has weak test cases or am I missing something crucial here?


Yes exactly, the element which is present in intersection of row and col is counted twice. I also got partially correct anyways I gave this test for fun and ended up getting frustrated for long queue, also the 0 sum problem was on GFG and all solutions are copied from their. Peace

i think answer should be min(N,ans) where N is number of targets and ans is sum of maximum frequencies of x and y coordinates

the actual problem with correct test cases-