We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
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.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Gemstones
You are viewing a single comment's thread. Return to all 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.