Problem max frequency character

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner cin = new Scanner(System.in);
String str = cin.nextLine();
int max = 0,index =-1;
for(int i = 0;i<str.length();i++){
int count = 0;
for(int j = 0;j<str.length();j++){
if(str.charAt(i) == str.charAt(j)){
count ++;
}
}
if(max<count){
max = count;
index = i;
}
}
System.out.print(str.charAt(index));
}
}======only one test case is not passed what’s the error

@AbhishekAhlawat1102
you can use hashmap in this problem and your code running fine.

@AbhishekAhlawat1102
mark your doubt as resolved and rate me as well.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.