Algorithm · Google · Medium
Follow-up This problem extends Find Maximum Length of Non-Decreasing Subarray Part 1. You may select one index and replace its value with any number. After making that change, determine the greatest possible length of a non-decreasing contiguous subarray. Using the earlier example, the result is: ans = 6, with the subarray [2 4 6 8 0 9]. Changing 0 -> 8 makes the entire subarray non-decreasing. Function signature Constraints: nums is an array of numbers. The value at the…
Checking your access…