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.
#include<stdio.h>#include<string.h>intmain(){charstr[1000];intcount=0;charnum_arr[10]={'0','1','2','3','4','5','6','7','8','9'};scanf("%s",str);for(inti=0;i<10;i++){count=0;//assigning count=0 for each digit 0-9for(intj=0;j<strlen(str);j++){if(str[j]==num_arr[i]){//find occurences of each digit in given string count++;}}printf("%d ",count);}return0;}
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 →