Can you please tell me what’s wrong with my code as I’m getting two cases failed.
//code
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str = sc.next();
int max=0;
String str1 = “”;
for(int i=0;i<str.length();i++) {
int count = 1;
while(i<str.length()-1 && str.charAt(i)==str.charAt(i+1)) {
count++;
i++;
}
if(max<count) {
max=count;
str1=str1+str.charAt(i);
}
}
System.out.print(str1);
}
}