SPOJ BROKEN WA

I am solving the Broken keyboard problem . I used the sliding window approach O(n) solution. but i’m getting wrong answer. Can anybody tell me where i went wrong ?. thanks in advance.

my solution: http://ideone.com/EiweVp
problem : spoj.com/problems/BROKEN/

your code gives wrong output for following case:
4

abcdcefe

0
you might have missed some minor test cases. The logic is correct :slight_smile: