2348 Number of Zero Filled Subarrays

Idea This is today’s daily challenge, I hate subarray problems as sometimes I tend to mess up with the sliding window pointer(especially the left pointer when shirking is needed). However, I learnt one thing from all those stupid subarray problems. Don’t care about the start of the subarray, always count how many subarrays END at current index By sticking to this rule, surprisingly I AC it in one shot… Solution 1 2 3 4 5 6 7 8 9 10 11 12 class Solution: def zeroFilledSubarray(self, nums: List[int]) -> int: l=r=0 res=0 ll=len(nums) while r<ll: if nums[r]==0: res+=r-l+1 else: l=r+1 r+=1 return res

March 21, 2023 · mimimi