package hackerrank;

import java.util.Scanner;

/**
 * https://www.hackerrank.com/challenges/alternating-characters
 */
public class AlternatingCharacters {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
    }
}

@@ -159,92 +159,588 @@
    p
-ublic static void main(String%5B%5D args) %7B%0A        Scanner in = new Scanner(System.in);
+rivate static int alternatingChars(String str) %7B%0A        char%5B%5D chars = str.toCharArray();%0A        int count = 0;%0A        char prev = chars%5B0%5D;%0A        for (int i = 1; i %3C chars.length; i++) %7B%0A            if (prev == chars%5Bi%5D) %7B%0A                count++;%0A            %7D%0A            prev = chars%5Bi%5D;%0A        %7D%0A        return count;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Scanner in = new Scanner(System.in);%0A        int testCases = in.nextInt();%0A        for (int t = 0; t %3C testCases; t++) %7B%0A            System.out.println(alternatingChars(in.next()));%0A        %7D
 %0A   

Solve Alternating Characters