<commit_before>package greedy;

/**
 * Created by Yue on 2017/11/4.
 * 665. Non-decreasing Array
 */
public class NonDecreasingArray {

    public static boolean checkPossibility(int[] nums) {
        if (nums.length <= 2)
            return true;
        int count = 0;
        for (int i = 0; i < nums.length - 1 && count <= 1; i++) {
            if (nums[i] > nums[i + 1]) {
                count++;
                nums[i] = nums[i + 1];
            }
        }
        return count <= 1;
    }

    public static void main(String[] args) {
        int[] nums = new int[] {3, 4, 2, 3};
        System.out.println(checkPossibility(nums));
    }
}
<commit_msg>add leetcode no.665<commit_after>package greedy;

/**
 * Created by Yue on 2017/11/4.
 * 665. Non-decreasing Array
 */
public class NonDecreasingArray {

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

    public static void main(String[] args) {
        int[] nums = new int[] {3, 4, 2, 3};
        System.out.println(checkPossibility(nums));
    }
}

{'fraction_non_alphanumeric': 0.14903129657228018, 'fraction_numerical': 0.03576751117734724, 'mean_word_length': 1.6806387225548902, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5305819', 'n_tokens_mistral': 510, 'n_tokens_neox': 453, 'n_words': 127}