@@ -0,0 +1,1030 @@
+import java.io.BufferedReader;%0Aimport java.io.IOException;%0Aimport java.io.InputStreamReader;%0A%0A// https://www.hackerrank.com/challenges/counting-valleys/problem%0Apublic class CountingValleys %7B%0A%0A    private static final char D = 'D';%0A    private static final char U = 'U';%0A%0A    private static String readPath() throws IOException %7B%0A        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) %7B%0A            reader.readLine(); // Ignore this line.%0A            return reader.readLine();%0A        %7D%0A    %7D%0A%0A    private static int countValleys(String path) %7B%0A        int seaLevel = 0;%0A        int valleys = 0;%0A        for (char c : path.toCharArray()) %7B%0A            if (seaLevel == 0 && c == D) %7B%0A                valleys += 1;%0A            %7D%0A            seaLevel += (c == U) ? 1: -1;%0A        %7D%0A        return valleys;%0A    %7D%0A%0A    public static void main(String%5B%5D args) throws IOException %7B%0A        String path = readPath();%0A        int valleys = countValleys(path);%0A        System.out.println(valleys);%0A    %7D%0A%7D%0A

Add solution for Counting valleys problem.