How to find the maximum occurring character in given String?
Answers
Answered by
1
Answer:
Logic to find maximum occurring character in string
- Input string from user, store it in some variable say str.
- Declare another array to store frequency of all alphabets, say freq [26]. ...
- Initialize frequencies of all alphabets in freq array to 0.
- Find frequency of each character present in the string.
- Maximum occurring character in string is maximum occurring value in the freq array.
Explanation:
Answered by
1
Answer:
JAVA
public class Characters.
{
public static void main(String[] args) {
String str = "grass is greener on the other side";
int[] freq = new int[str.length()];
char minChar = str.charAt(0), maxChar = str.charAt(0);
int i, j, min, max;
//Converts given string into character array.
Similar questions