problem link : https://www.codechef.com/problems/COPS
solution : https://www.codechef.com/viewsolution/16696107
why my answer yields WA… I have checked all boundary and possible cases too…Please help.
problem link : https://www.codechef.com/problems/COPS
solution : https://www.codechef.com/viewsolution/16696107
why my answer yields WA… I have checked all boundary and possible cases too…Please help.
Don’t make it complex by using so many conditions and it can be simply solved in nearly O(n) time.
Simple Approach:
maxDis = x*y;
vis[101] -> Array to keep track of visited positions.
Just run a loop over Array A and run two loops inside:
current_pos = a[i] (Say, i as your iterator)
Loop over your vis array and count those positions which are 0. This is your final answer.
Here is my Solution : Link