Non-decreasing Array
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
Given an integer array nums, return true if you can make it non-decreasing by changing the value of **at most one** element (to any integer you like), and false otherwise.
An array is non-decreasing when nums[i] <= nums[i + 1] for every valid i. Equal neighbors are fine.
Solve it in one O(n) pass with O(1) extra space.
Examples
Constraints
- 1 <= nums.length <= 10^4
- -10^5 <= nums[i] <= 10^5
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.