@@ -0,0 +1,821 @@
+import java.io.*;%0Aimport java.util.*;%0Aimport java.text.*;%0Aimport java.math.*;%0Aimport java.util.regex.*;%0A%0Apublic class Solution %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A        Scanner sc=new Scanner(System.in);%0A        int n = sc.nextInt();%0A        for(int i=0;i%3Cn;i++)%7B%0A            String s = sc.next();%0A            Stack%3CCharacter%3E st = new Stack%3CCharacter%3E();%0A            char%5B%5D c = s.toCharArray();%0A            int count = 0;%0A            for(int j=0;j%3Cc.length;j++)%7B%0A                if(st.isEmpty())%7B%0A                    st.push(c%5Bj%5D);%0A                    continue;%0A                %7D%0A                else if(st.peek()==c%5Bj%5D)%7B%0A                    count++;%0A                    continue;%0A                %7D%0A                else st.push(c%5Bj%5D);%0A            %7D%0A            System.out.println(count);%0A        %7D%0A    %7D%0A%7D%0A

add AlternatingCharacters.java