package leetcode;

/**
 * https://leetcode.com/problems/non-decreasing-array/
 */
public class Problem665 {
    public boolean checkPossibility(int[] nums) {
        // TODO
        return false;
    }

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

@@ -163,291 +163,1585 @@
     
-// TODO%0A        return false;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem665 prob = new Problem665();%0A        System.out.println(prob.checkPossibility(new int%5B%5D%7B4, 2, 3%7D)); // true%0A        System.out.println(prob.checkPossibility(new int%5B%5D%7B4, 2, 1%7D)); // fals
+if (nums.length == 1) %7B%0A            return true;%0A        %7D%0A        int prev = 0;%0A        int count = 0;%0A        for (int curr = 1; curr %3C nums.length; curr++) %7B%0A            if (nums%5Bprev%5D %3E nums%5Bcurr%5D) %7B%0A                if (prev == 0) %7B%0A                    nums%5Bprev%5D = Integer.MIN_VALUE;%0A                %7D else %7B%0A                    if (nums%5Bprev%5D == nums%5Bprev - 1%5D) %7B%0A                        nums%5Bcurr%5D = nums%5Bprev%5D;%0A                    %7D else %7B%0A                        nums%5Bprev%5D = nums%5Bprev - 1%5D;%0A                    %7D%0A                    if (nums%5Bprev%5D %3E nums%5Bcurr%5D) %7B%0A                        return false;%0A                    %7D%0A                %7D%0A                count++;%0A                if (count == 2) %7B%0A                    return false;%0A                %7D%0A            %7D%0A            prev = curr;%0A        %7D%0A        return true;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem665 prob = new Problem665();%0A        System.out.println(prob.checkPossibility(new int%5B%5D%7B4, 2, 3%7D)); // true%0A        System.out.println(prob.checkPossibility(new int%5B%5D%7B4, 2, 1%7D)); // false%0A        System.out.println(prob.checkPossibility(new int%5B%5D%7B1, 5, 2, 4%7D)); // true%0A        System.out.println(prob.checkPossibility(new int%5B%5D%7B1%7D)); // true%0A        System.out.println(prob.checkPossibility(new int%5B%5D%7B3, 4, 2, 3%7D)); // false%0A        System.out.println(prob.checkPossibility(new int%5B%5D%7B-1, 4, 2, 3%7D)); // true%0A        System.out.println(prob.checkPossibility(new int%5B%5D%7B2, 3, 3, 2, 4%7D)); // true%0A        System.out.println(prob.checkPossibility(new int%5B%5D%7B1, 2, 4, 5, 3%7D)); // tru
 e%0A  

Update problem 665