From left to right, find the potential start s where nums[s+1]<nums[s]

From right to left, find the potential end e where nums[e]<nums[e-1]

Find the min value and max value of the elements between start and end, compare them with the numbers from 0 to s and e to length -1. Update the start and end.

Return end - start + 1