Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit dc83689

Browse files
committed
Time: 7 ms (58.71%) | Memory: 23.2 MB (58.85%) - LeetSync
1 parent 858813d commit dc83689

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution:
2+
def canThreePartsEqualSum(self, arr: List[int]) -> bool:
3+
total = sum(arr)
4+
if total % 3 != 0:
5+
return False
6+
target = total // 3
7+
current_sum = 0
8+
partitions = 0
9+
for i in range(len(arr)):
10+
current_sum += arr[i]
11+
if current_sum == target:
12+
partitions += 1
13+
current_sum = 0
14+
if partitions == 2 and i < len(arr) - 1:
15+
return True
16+
return False

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /