#3738
Longest Non-Decreasing Subarray After Replacing at Most One Element
medium · 21.6% accepted · 93 likes · top 2%
Description
You are given an integer array nums.
You are allowed to replace at most one element in the array with any other integer value of your choice.
Return the length of the longest non-decreasing subarray that can be obtained after performing at most one replacement.
An array is said to be non-decreasing if each element is greater than or equal to its previous one (if it exists).
Solution