• + 0 comments

    Have a close look at it:

    "if (letter[c - 'a'] == r) { letter[c - 'a']++; "

    If repeated character is met, this 'if' condition will fail because at first, if condition is passed but after it the letter[c - 'a'] is incremented, but the r's value is still same say '0' for 1st iteration then letter[c - 'a'] will be 1 which leads to failing of this 'if' case for 2nd iteration.