1498 Number of Subsequences That Satisfy the Given Sum Condition

1498. Number of Subsequences That Satisfy the Given Sum Condition I hate these array problem and subsequences… This is the daily challenge on 6 May 2023, I opened up the submission tab and found that I tried this problem 1 year ago and from the submission history, I recall how miserable it was… Idea I usually look for two ways to solve array+subsequence problem. DP Two pointers This problem has a test case size of \(10^5\), so DP is out of the game, and two pointer does seem promising....

May 6, 2023 · mimimi

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