what is the mistake in this logic ? Can anyone help?
Bro as per the constraints, the value of N can be 1 also.
So think about it, like if there were no “0’s” or no “1’s” in the array, your code would give wrong ans.
Consider following test-cases:
2 1 100 2 1 1 85 7 0
Your Code Output:
Your code is giving WA because of the overflow in
mnF + mnD because you have initialised it with
INT_MAX rather initialise it with
101 according to the constraints or if you want to go with
INT_MAX then change the data-type of
long long int rather that
// int mnF = INT_MAX, mnD = INT_MAX; int mnF = 101, mnD = 101;
Updated Code (AC): CodeChef: Practical coding for everyone
thankyou bro, I got my mistake now.