@@ -0,0 +1,2232 @@
+public class LongestMountainArray %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A        System.out.println(new LongestMountainArray().longestMountain(new int%5B%5D%7B875,884,239,731,723,685%7D));%0A        System.out.println(new LongestMountainArray().longestMountain(new int%5B%5D%7B9, 8, 7, 6, 5, 4, 3, 2, 1, 0%7D));%0A        System.out.println(new LongestMountainArray().longestMountain(new int%5B%5D%7B0, 2, 2%7D));%0A        System.out.println(new LongestMountainArray().longestMountain(new int%5B%5D%7B0, 1, 2, 3, 4, 5, 6, 7, 8, 9%7D));%0A        System.out.println(new LongestMountainArray().longestMountain(new int%5B%5D%7B2, 1, 4, 7, 3, 2, 5%7D));%0A        System.out.println(new LongestMountainArray().longestMountain(new int%5B%5D%7B2, 2, 2%7D));%0A        System.out.println(new LongestMountainArray().longestMountain(new int%5B%5D%7B3, 3, 1%7D));%0A        System.out.println(new LongestMountainArray().longestMountain(new int%5B%5D%7B0, 1, 0%7D));%0A    %7D%0A%0A    public int longestMountain(int%5B%5D arr) %7B%0A        if (arr.length %3C 3) %7B%0A            return 0;%0A        %7D%0A        int maxMountainSize = 0;%0A        for (int j = 0; j %3C arr.length - 2; j++) %7B%0A            int mountainSize = getMountainSize(arr, j);%0A            if (mountainSize %3E maxMountainSize) %7B%0A                maxMountainSize = mountainSize;%0A                j += mountainSize - 2;%0A            %7D%0A        %7D%0A        return maxMountainSize;%0A    %7D%0A%0A    private int getMountainSize(int%5B%5D numbers, int from) %7B%0A        if (numbers.length - from %3C 3) %7B%0A            return 0;%0A        %7D%0A        boolean goingUp = true;%0A        int pickIndex = 0;%0A        for (int i = from; i %3C numbers.length - 1; i++) %7B%0A            if (goingUp) %7B%0A                if (numbers%5Bi%5D %3E= numbers%5Bi + 1%5D) %7B%0A                    if (i == from) %7B%0A                        return 0;%0A                    %7D%0A                    goingUp = false;%0A                    pickIndex = i;%0A                    i--;%0A                %7D%0A            %7D else %7B%0A                if (numbers%5Bi%5D %3C= numbers%5Bi + 1%5D) %7B%0A                    if (i == pickIndex) %7B%0A                        return 0;%0A                    %7D%0A                    return i - from + 1;%0A                %7D%0A            %7D%0A        %7D%0A        if (goingUp) %7B%0A            return 0;%0A        %7D%0A        return numbers.length - from;%0A    %7D%0A%7D%0A

Add LongestMountainArray