2. 参考Prefix Sum & Dictionary Time and Space O(n) for -- Find a number of continuous subarrays/submatrices/tree paths that sum to targetT: O(n), S: O(n) classSolution:defsubarraySum(self, nums: List[int], target: int) ->int: count, curSum, d=0, 0, collections.Counter()forn...
遍历+比较最大值+时间O(n) Python3 解题思路 此处撰写解题思路 代码 classSolution:defnumTimesAllBlue(self,light:List[int])->int:sum1=0max1=0foriinrange(len(light)):max1=max(max1,light[i])ifi+1==max1:sum1+=1returnsum1 下一篇题解 ...
FindHeaderBarSize FindTabBarSize 有一个书店老板,他的书店开了n分钟。每分钟都有一些顾客进入这家商店。给定一个长度为n的整数数组customers,其中customers[i]是在第i分钟开始时进入商店的顾客数量,所有这些顾客在第i分钟结束后离开。 在某些分钟内,书店老板会生气。 如果书店老板在第i分钟生气,那么grumpy[i] = ...