```
class Solution {
public boolean checkPossibility(int[] nums) {
int count = 0;
for(int i = 0; i < nums.length-1; i++){
if(nums[i] > nums[i+1]){
// consider i+2
if(i+2 >= nums.length || (nums[i+2] >= nums[i])){
nums[i+1] = nums[i];
}
else if(i-1 < 0 || (nums[i+1] >= nums[i-1])){
nums[i] = nums[i+1];
}
else
return false;
count++;
}
}
return count <= 1;
}
}
```