Implement the below function to print the count of numeric characters (0-9) in a given string and also print the count of remaining characters. (Ignore the character cases, it can be lower or upper case)
The function will take 1 parameter which will be a String (or a character array). You do not have to write code to get the input parameter from the user.
int frequencyOfNumericChars(String input) {
// TODO: Add code here
}
Example:
Input: raja1123labs Output:=’1’=2, ‘2’=1, ‘3’=1, others=8
Input: Buffet101 Output: ‘1’=2, ‘0’=1, others=6
str1 = "raja1123labs";
fy = [None] * len(str1);
for i in range(0, len(str1)):
fy[i] = 1;
for j in range(i+1, len(str1)):
if(str1[i] == str1[j]):
fy[i] = fy[i] + 1;
str1 = str1[ : j] + '0' + str1[j+1 : ];
for i in range(0, len(fy)):
if(str1[i] != ' ' and str1[i] != '0'):
print(str1[i] + "-" + str(fy[i]));
Comments
Leave a comment