2155. All Divisions With the Highest Score of a Binary Array
Содержание
class Solution:
def maxScoreIndices(self, nums: List[int]) -> List[int]:
left, right = 0, sum(nums)
mx = right
res = [0]
for i, num in enumerate(nums):
if num == 0:
left += 1
else:
right -= 1
t = left + right
if mx == t:
res.append(i + 1)
elif mx < t:
mx = t
res = [i + 1]
return res