package leetcode;

/**
 * https://leetcode.com/problems/valid-mountain-array/
 */
public class Problem941 {
    public boolean validMountainArray(int[] A) {
        // TODO
        return false;
    }

    public static void main(String[] args) {
        Problem941 prob = new Problem941();
        System.out.println(prob.validMountainArray(new int[]{2, 1})); // false
        System.out.println(prob.validMountainArray(new int[]{3, 5, 5})); // false
        System.out.println(prob.validMountainArray(new int[]{0, 3, 2, 1})); // true
        System.out.println(prob.validMountainArray(new int[]{0, 3, 2, 1, 5})); // false
        System.out.println(prob.validMountainArray(new int[]{3, 5, 5, 2})); // false
    }
}

@@ -162,16 +162,33 @@
     
-// TODO%0A
+if (A.length %3C= 2) %7B%0A    
     
@@ -213,260 +213,267 @@
     
-%7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem941 prob = new Problem941();%0A        System.out.println(prob.validMountainArray(new int%5B%5D%7B2, 1%7D)); // false%0A        System.out.println(prob.validMountainArray(new int%5B%5D%7B3, 5, 5%7D)); //
+    %7D%0A        boolean increasing = true;%0A        boolean decreasing = false;%0A        for (int i = 0, j = 1; j %3C A.length; i++, j++) %7B%0A            if ((increasing && A%5Bi%5D %3E= A%5Bj%5D) %7C%7C%0A                (decreasing && A%5Bi%5D %3C= A%5Bj%5D)) %7B%0A                return
  false
+;
 %0A   
@@ -481,171 +481,143 @@
     
-System.out.println(prob.validMountainArray(new int%5B%5D%7B0, 3, 2, 1%7D)); // true%0A        System.out.println(prob.validMountainArray(new int%5B%5D%7B0, 3, 2, 1, 5%7D)); //
+    %7D%0A            if (A%5Bi%5D %3C A%5Bj%5D) %7B%0A                if (j + 1 %3C A.length && A%5Bj%5D %3E A%5Bj + 1%5D) %7B%0A                    increasing =
  false
+;
 %0A   
@@ -625,84 +625,122 @@
     
-System.out.println(prob.validMountainArray(new int%5B%5D%7B3, 5, 5, 2%7D)); // false
+            decreasing = true;%0A                %7D%0A            %7D%0A        %7D%0A        return !increasing && decreasing;
 %0A   

Solve problem 941