Given an array nums with n integers, check whether it could become non-decreasing by modifying at most one element. The array is non-decreasing if nums[i] <= nums[i + 1] holds for every i (0-based) such that 0 <= i <= n - 2.
Given an array nums with n integers, check whether it could become non-decreasing by modifying at most one element. The 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: true
Constraints:
n=nums.length
1≤n≤104
−105≤nums[i]≤105
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"nums":[4,2,3]}
One repair token is available. Walk the array and spend it only where a bar is lower than the bar to its left.
repair token:
unused
nums: blue = checked and in order, orange = i, purple = i - 1, teal = i - 2