# [Java][Greedy][LeetCode] Non-decreasing Array #665

Given an array `nums` with `n` integers, your task is to check if it could become non-decreasing by modifying at most one element.

We define an array is non-decreasing if `nums[i] <= nums[i + 1]` holds for every `i` (0-based) such that (`0 <= i <= n - 2`).

Example 1:

`Input: nums = [4,2,3]Output: trueExplanation: You could modify the first 4 to 1 to get a non-decreasing array.`

One by one to look for the point that happen decreasing. The counter will +1 when the event was happened. Because array can be modified one time. So, if count>1, return false to end of this procedure.
In order to remain the array is non-decreasing array. when the event happen, I need to check previous element. Assume current point is [i], previous point is [i-1], and so on. If [i-2]<=[i], I need to replace value of [i] to [i-2]. If [i-2]>[i], I need to replace value of [i-1] to [i]. As mention above, array will keep in ascending order. But, keep an important in mind. when counter>1 will return false.