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

歡迎光臨散文網(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的評論 (共 條)

分享到微博請遵守國家法律
庐江县| 棋牌| 彩票| 巴塘县| 成安县| 禹州市| 阳泉市| 海安县| 白城市| 禹州市| 合水县| 汽车| 黔西| 中西区| 沛县| 扬州市| 深圳市| 东乌珠穆沁旗| 德保县| 水富县| 德昌县| 毕节市| 九龙坡区| 拉萨市| 临高县| 平果县| 琼海市| 博罗县| 高唐县| 樟树市| 浙江省| 磐安县| 佛教| 喜德县| 许昌县| 天门市| 从化市| 建始县| 台山市| 黑山县| 蒲城县|