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.
the simpple logic is
for (int i = 0; i < strlen(s); i++) {
if (s[i] >= '0' && s[i] <= '9') {
freq[s[i] - '0']++;
}
}
here we can check the condition given and store it in a frequency array that we created previously
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Digit Frequency
You are viewing a single comment's thread. Return to all comments →
the simpple logic is for (int i = 0; i < strlen(s); i++) { if (s[i] >= '0' && s[i] <= '9') { freq[s[i] - '0']++; } } here we can check the condition given and store it in a frequency array that we created previously