var findUnsortedSubarray = function(nums) {
let len = nums.length;
let min = nums[len-1];
let max = nums[0];
let start = 0,end = -1;
for(let i=0;i<len;i++){
if(nums[i]<max){
end = i;
}else{
max = nums[i];
}
if(nums[len-i-1]>min){
start = len-i-1;
}else{
min = nums[len-i-1];
}
}
return end-start+1;
};
581
- 本文链接:http://gulinga.github.io/2022/09/21/arithmetic/LeetCode%E7%83%AD%E9%A2%98HOT100/581/
- 版权声明:本博客所有文章除特别声明外,均默认采用 许可协议。