【知识图谱】【算法】-- 双指针类
2021-08-06 00:56
标签:fas lang 代码 策略 com http math 指针 pre 1. 长度最小的子数组 20210629晚 来源链接:leetCode:209 确定快慢指针移动的策略 点击查看代码var minSubArrayLen = function(target, nums) { let slow = 0; let fast = 0; let sum = 0; let minLength = 0; while(fast = target){// 2. 当和大于等于目标值时,进行慢指针的移动[重点][慢指针的运动策略] while(sum >= target){ sum -= nums[slow]; // 3. 更新最小长度 minLength = minLength == 0 ? (fast - slow + 1) : Math.min(minLength,(fast-slow+1)); slow++; } } fast++; } return minLength; }; 【知识图谱】【算法】-- 双指针类标签:fas lang 代码 策略 com http math 指针 pre 原文地址:https://www.cnblogs.com/Neilisme/p/14952580.html