Please help me in REPLESX

This is the final code I submitted for REPLESX in October Long Challenge. I had rectified many times and this was my final code but still I got WA. Please help me to figure out a testcase I was missing.

Question Link :- https://www.codechef.com/OCT20B/problems/REPLESX

My code Link :- https://www.codechef.com/viewsolution/38887572

Your code is giving wrong answer in case where there are multiple possible positions of x (i.e there are multiple occurrences of x are present in array then you’ve to find the optimal(minimum) one. I’ve gone through your solution and here’s the test case where it fails

1
8 3 5 7
1 3 3 3 10 12 13 14

correct answer will be 1 but your code gives 3 as answer which is wrong.
Here’s link to my submission for this problem I advice you to see how I am handling multiple position of x to find optimal(minimum) answer. Hope you get it.

1 Like