package leetcode;

/**
 * https://leetcode.com/problems/monotonic-array/
 */
public class Problem896 {
    public boolean isMonotonic(int[] A) {
        // TODO
        return false;
    }

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

@@ -150,131 +150,181 @@
     
-// TODO%0A        return fals
+int cmp = 0;%0A        boolean first = tru
 e;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem896 prob = new Problem896(
+for (int j = 0, i = 1; i %3C A.length; i++, j++) %7B%0A            if (first) %7B%0A                cmp = Integer.compare(A%5Bj%5D, A%5Bi%5D
 );%0A 
@@ -334,379 +334,323 @@
     
+  
-System.out.println(prob.isMonotonic(new int%5B%5D%7B1, 2, 2, 3%7D)); // true%0A        System.out.println(prob.isMonotonic(new int%5B%5D%7B6, 5, 4, 4%7D)); // true%0A        System.out.println(prob.isMonotonic(new int%5B%5D%7B1, 3, 2%7D)); // false%0A        System.out.println(prob.isMonotonic(new int%5B%5D%7B1, 2, 4, 5%7D)); // true%0A        System.out.println(prob.isMonotonic(new int%5B%5D%7B1, 1, 1%7D)); //
+      first = false;%0A            %7D else %7B%0A                int c = Integer.compare(A%5Bj%5D, A%5Bi%5D);%0A                if (cmp == 0) %7B%0A                    cmp = c;%0A                %7D%0A                if (c != cmp && c != 0) %7B%0A                    return false;%0A                %7D%0A            %7D%0A%0A        %7D%0A        return
  true
+;
 %0A   

Solve problem 896