Array occurrence

how to count occurrence of a digit in array elemrnt

1 Like

this article would be helpfull

In python :
arr = [1,2,3,3,3,3,4,5]
print (arr.count(3))
Output 4

The clearer the question asked, the clearer the answer received will be

Maybe you are asking count of unique element in an array
int count=1;
sort(arr,arr+n);
for(int i=0;i<n;i++){
if(i!=n-1 and arr[i]!=arr[i+1]){
count++;
}
cout<<count<<endl;

I guess u are asking this:

li = [122, 244, 356, 1234555322, 2235222]

digit = int(input())

for i in li:
    print(str(i).count(str(digit)))