Leetcode 1062 Solution
This article provides solution to leetcode question 1062 (partition-array-into-three-parts-with-equal-sum)
Access this page by simply typing in "lcs 1062" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/partition-array-into-three-parts-with-equal-sum
Solution
class Solution(object):
def canThreePartsEqualSum(self, A):
"""
:type A: List[int]
:rtype: bool
"""
s = sum(A)
if s % 3 != 0:
return False
cur = 0
part = 0
for a in A:
cur += a
if cur == s / 3:
cur = 0
part += 1
return part >= 3