最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

LeetCode 930. Binary Subarrays With Sum

2023-04-14 14:14 作者:您是打尖兒還是住店呢  | 我要投稿

Given a binary array?nums?and an integer?goal, return?the number of non-empty?subarrays?with a sum?goal.

A?subarray?is a contiguous part of the array.

?

Example 1:

Input: nums = [1,0,1,0,1], goal = 2

Output: 4

Explanation:?

The 4 subarrays are bolded and underlined below:?

[1,0,1,0,1]

[1,0,1,0,1]?

[1,0,1,0,1]?

[1,0,1,0,1]

Example 2:

Input: nums = [0,0,0,0,0], goal = 0

Output: 15

?pre_sum題型,會了1道,其他的基本都會了。

Constraints:

  • 1 <= nums.length <= 3 * 104

  • nums[i]?is either?0?or?1.

  • 0 <= goal <= nums.length


Runtime:?2241 ms, faster than?5.07%?of?Java?online submissions for?Binary Subarrays With Sum.

Memory Usage:?47 MB, less than?41.47%?of?Java?online submissions for?Binary Subarrays With Sum.


LeetCode 930. Binary Subarrays With Sum的評論 (共 條)

分享到微博請遵守國家法律
沈阳市| 木里| 自贡市| 饶河县| 西充县| 娄烦县| 郑州市| 西和县| 石楼县| 逊克县| 景德镇市| 平乐县| 祥云县| 山西省| 昭通市| 阿坝| 六盘水市| 永登县| 同心县| 新晃| 青河县| 哈密市| 阜康市| 城固县| 连南| 五家渠市| 喀什市| 平凉市| 类乌齐县| 玛多县| 安宁市| 苏尼特左旗| 西昌市| 桂平市| 大理市| 天台县| 石景山区| 德令哈市| 浙江省| 海晏县| 皮山县|