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

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

Leetcode 1013. Partition Array Into Three Parts With Equal Sum

2023-03-01 11:23 作者:您是打尖兒還是住店呢  | 我要投稿

Given an array of integers?arr, return?true?if we can partition the array into three?non-empty?parts with equal sums.

Formally, we can partition the array if we can find indexes?i + 1 < j?with?(arr[0] + arr[1] + ... + arr[i] == arr[i + 1] + arr[i + 2] + ... + arr[j - 1] == arr[j] + arr[j + 1] + ... + arr[arr.length - 1])

?

Example 1:

Input: arr = [0,2,1,-6,6,-7,9,1,2,0,1]Output: trueExplanation: 0 + 2 + 1 = -6 + 6 - 7 + 9 + 1 = 2 + 0 + 1

Example 2:

Input: arr = [0,2,1,-6,6,7,9,-1,2,0,1]Output: false

Example 3:

Input: arr = [3,3,6,5,-2,2,5,1,-9,4]Output: trueExplanation: 3 + 3 = 6 = 5 - 2 + 2 + 5 + 1 - 9 + 4

?

Constraints:

  • 3 <= arr.length <= 5 * 104

  • -104?<= arr[i] <= 104

Easy 題目,少考慮了一件事情,就是分3份,分完了還剩下一些,怎么辦,就是直接累加是否等于0,即可;



Runtime:?3 ms, faster than?32.14%?of?Java?online submissions for?Partition Array Into Three Parts With Equal Sum.

Memory Usage:?50 MB, less than?87.32%?of?Java?online submissions for?Partition Array Into Three Parts With Equal Sum.


Leetcode 1013. Partition Array Into Three Parts With Equal Sum的評論 (共 條)

分享到微博請遵守國家法律
民勤县| 杨浦区| 神木县| 凤台县| 沅江市| 阜新市| 宜都市| 邹城市| 习水县| 桃源县| 庆元县| 新野县| 黑山县| 张掖市| 齐齐哈尔市| 麟游县| 安仁县| 交城县| 雷山县| 楚雄市| 通城县| 香河县| 临洮县| 扬州市| 蒙城县| 新泰市| 抚州市| 惠州市| 铜梁县| 容城县| 抚州市| 广饶县| 呼玛县| 宣化县| 宜黄县| 敖汉旗| 顺义区| 吉安县| 汾西县| 建瓯市| 香港 |