# CYSM - Editorial

Practice

Contest

Author: Arindam Baidya

Tester: Chinmay Rakshit

Editorialist: Chinmay Rakshit

CAKEWALK.

HASHING

### PROBLEM:

Given the big integer n you have to find the number of times, an integer q repeats itself in n.

### EXPLANATION:

There can be many approaches by the most simple is to use

a map of <char,int> this will store the frequency of each integer (0-9)

let’s take the input “big integer n” as the string now compute the frequency by just traversing each character and storing its count.

print the count as print(m[q]) where q is a character

### ALTERNATIVE SOLUTION:

Alternatively, it can be solved by taking the input as long long int as it will encompass the input and store the frequency of each integer in an array[0-9].And then take the input q and print (array[q])

### AUTHOR’S AND TESTER’S SOLUTIONS:

Author’s solution can be found here.

Tester’s solution can be found here.

int main(){
ios::sync_with_stdio(false);
int t,ans,q;
char a;
cin>>t;
while(t–){
fill(ans,ans+10,0);
cin>>a;
for(int i=0;a[i]!=’\0’;i++)
ans[a[i]-‘0’]+=1;
cin>>q;
cout<<ans[q]<<"\n";
}
return 0;
}