You are viewing a single comment's thread. Return to all comments →
Scanner in =new Scanner(System.in); int n=in.nextInt();
for(int i=0; i<n; i++) { int count=0; String s=in.next(); int l=s.length(); for(int j=0; j<l-1;j++) { if(s.charAt(j)==s.charAt(j+1)) { count++; } } System.out.println(count); }
Seems like cookies are disabled on this browser, please enable them to open this website
Alternating Characters
You are viewing a single comment's thread. Return to all comments →
Scanner in =new Scanner(System.in); int n=in.nextInt();