I suppose by Monogon Monogon's solution for this problem that the sufficient and necessary condition is 2*f <= 2*n -x-y , where f = number of most frequent color after making x matches. so in my solution when I write only this condition it gives the wrong answer on test case(2) first solution but after adding an extra condition it gets accepted corrected . can someone explain, please??