YouTube video link : click here Question link : click here
Solution : in Java
import java.util.Scanner;
public class StonesontheTable {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
char ch[] = sc.next().toCharArray();
int count = 0;
for(int i=0;i<n-1;i++){
if(ch[i]==ch[i+1]){
count++;
}
}
System.out.println(count);
}
}
______________________________________________
Thanks for visiting
0 Comments