Find Your Gift | CodeChef

plz see into my submission
it is showing WA always
https://www.codechef.com/viewsolution/30664999

for(int k=j+1;k<n;k++)
In this loop, in case k=n-1, you are trying to compare s[k+1] to something else, but s[k+1] is equal to s[n] in this case, which does not exist and will cause error.

1 Like