You are given an integer 'N'.
Return the count of repeating digits in 'N'.
Let 'N' = 9397776.
The repeating digits in 'N' are 9 and 7.
Therefore, the answer is 2.
The first line contains an integer 'N'.
Output Format :
Return the count of repeating digits in 'N'.
Note :
You don’t need to print anything. Just implement the given function.
0 <= 'N' <= 10^9
Time Limit: 1 sec
12345
0
The digits in the given number are 1, 2, 3, 4, and 5.
None of these digits repeat.
Thus, the answer is 0.
14312
1
Keep track of the digits you have encountered.
Approach:
Algorithm:
O(D), where 'D' is the number of digits in 'N'.
We iterate through the digits of 'N' once and then iterate through a constant size array (10). Thus the overall time complexity is of the order O(D).
O(1).
We create an array of size 10 to store the frequency of digits. Thus, the overall space complexity is of the order O(1).