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.
r is 0 for first string , first condition
"if (letter[c - 'a'] == r) { letter[c - 'a']++;"
will increase the letter's index only once throught the whole string if a particular character occures even multiple times. and second condition
if (letter[c - 'a'] == rocks) { count++; } means if the particular index is equals to the number of string entered means it's present in every string so increase the counter.
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 →
r is 0 for first string , first condition "if (letter[c - 'a'] == r) { letter[c - 'a']++;" will increase the letter's index only once throught the whole string if a particular character occures even multiple times. and second condition if (letter[c - 'a'] == rocks) { count++; } means if the particular index is equals to the number of string entered means it's present in every string so increase the counter.