classSolution:defminSubArrayLen(self,target:int,nums: List[int]) ->int: ans =float('inf') fast =0 slow =0 acc =0while fast <len(nums): num = nums[fast] fast +=1 acc += numwhile acc >= target: ans =min(ans, fast - slow) d = nums[slow] slow +=1 acc -= dreturn0if ans ==float('inf')else ans
classSolution:defminSubArrayLen(self,target:int,nums: List[int]) ->int: ans =float('inf') fast =0 slow =0 acc =0while fast <len(nums): num = nums[fast] fast +=1 acc += numwhile acc >= target: d = nums[slow] slow +=1 acc -= d ans =min(ans, fast - slow +1)return0if ans ==float('inf')else ans