https://www.codechef.com/viewsolution/33331895
Can anyone please suggest the testcase where it fails.
https://www.codechef.com/viewsolution/33331895
Can anyone please suggest the testcase where it fails.
it seem your isPresent function never returns false because i<n is always true as in the loop i runs from 0 to n-1;
i runs from 0 to n - 1, but if the break condition is not reached, then i will equal to n, at the end.
This is because when i = n - 1, the condition will work, but in the next iteration, i = n, and the condition for the loop is not satisfied, so the processor comes outside the loop.