五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

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

Leetcode 2395. Find Subarrays With Equal Sum

2023-01-21 10:41 作者:您是打尖兒還是住店呢  | 我要投稿

Given a?0-indexed?integer array?nums, determine whether there exist?two?subarrays of length?2?with?equal?sum. Note that the two subarrays must begin at?different?indices.

Return?true?if these subarrays exist, and?false?otherwise.

A?subarray?is a contiguous non-empty sequence of elements within an array.

?

Example 1:

Input: nums = [4,2,4]Output: trueExplanation: The subarrays with elements [4,2] and [2,4] have the same sum of 6.

Example 2:

Input: nums = [1,2,3,4,5]Output: falseExplanation: No two subarrays of size 2 have the same sum.

Example 3:

Input: nums = [0,0,0]Output: trueExplanation: The subarrays [nums[0],nums[1]] and [nums[1],nums[2]] have the same sum of 0. Note that even though the subarrays have the same content, the two subarrays are considered different because they are in different positions in the original array.

?

Constraints:

  • 2 <= nums.length <= 1000

  • -109?<= nums[i] <= 109

hashmap基礎(chǔ)題目,

判斷能否有,將所有2個連續(xù)size的數(shù)組和放進map中,

遍歷map,如果有value>1的,則存在,返回true,否則返回false;

Runtime:?1 ms, faster than?96.91%?of?Java?online submissions for?Find Subarrays With Equal Sum.

Memory Usage:?40.1 MB, less than?86.76%?of?Java?online submissions for?Find Subarrays With Equal Sum.


Leetcode 2395. Find Subarrays With Equal Sum的評論 (共 條)

分享到微博請遵守國家法律
米易县| 临江市| 哈巴河县| 凤翔县| 西乌珠穆沁旗| 正阳县| 巴彦淖尔市| 咸阳市| 泾源县| 乐都县| 江孜县| 习水县| 台中县| 安平县| 张北县| 宽城| 咸阳市| 福鼎市| 九江县| 德格县| 平顶山市| 平凉市| 武汉市| 苏州市| 文安县| 台北市| 平南县| 建宁县| 咸宁市| 彭泽县| 新安县| 新闻| 桂平市| 水富县| 金溪县| 铜陵市| 永清县| 藁城市| 崇仁县| 泽州县| 获嘉县|