package leetcode;

/**
 * https://leetcode.com/problems/longest-mountain-in-array/
 */
public class Problem845 {
    public int longestMountain(int[] A) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem845 prob = new Problem845();
        System.out.println(prob.longestMountain(new int[]{2, 1, 4, 7, 3, 2, 5})); // 5
        System.out.println(prob.longestMountain(new int[]{2, 2, 2})); // 0
    }
}

@@ -160,15 +160,731 @@
     
-// TODO
+int left = 0;%0A        int right = -1;%0A        int i = 0;%0A        int prev = Integer.MIN_VALUE;%0A        int result = 0;%0A        while (i %3C A.length) %7B%0A            if (prev %3C A%5Bi%5D) %7B%0A                if (left %3E= 0 && right %3E= 0) %7B%0A                    result = Math.max(result, right - left + 1);%0A                    left = right;%0A                    right = -1;%0A                %7D%0A                prev = Math.max(prev, A%5Bi%5D);%0A            %7D else if (prev %3E A%5Bi%5D) %7B%0A                prev = Math.min(prev, A%5Bi%5D);%0A                right = i;%0A            %7D else %7B%0A                // TODO%0A            %7D%0A            i++;%0A        %7D%0A        if (left %3E= 0 && right %3E= 0) %7B%0A            result = Math.max(result, right - left + 1);%0A        %7D
 %0A   
@@ -895,17 +895,22 @@
  return 
-0
+result
 ;%0A    %7D%0A
@@ -999,16 +999,18 @@
 m845();%0A
+//
         
@@ -1088,16 +1088,18 @@
 ); // 5%0A
+//
         
@@ -1165,16 +1165,331 @@
 ); // 0%0A
+//        System.out.println(prob.longestMountain(new int%5B%5D%7B1, 1, 2, 3, 4, 2, 3, 2%7D)); // 5%0A        System.out.println(prob.longestMountain(new int%5B%5D%7B2, 1%7D)); // 0%0A//        System.out.println(prob.longestMountain(new int%5B%5D%7B1, 2%7D)); // 0%0A//        System.out.println(prob.longestMountain(new int%5B%5D%7B1, 2, 1%7D)); // 3%0A
     %7D%0A%7D%0A

Update problem 845