This commit is contained in:
parent
6cda4101f9
commit
a89091c155
1 changed files with 15 additions and 0 deletions
15
medium/number_of_ways_to_split_arrays.py
Normal file
15
medium/number_of_ways_to_split_arrays.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# https://leetcode.com/problems/number-of-ways-to-split-array
|
||||
|
||||
from typing import List
|
||||
|
||||
class Solution:
|
||||
def waysToSplitArray(self, nums: List[int]) -> int:
|
||||
result = 0
|
||||
right = sum(nums)
|
||||
left = 0
|
||||
for i in range(len(nums) - 1):
|
||||
right -= nums[i]
|
||||
left += nums[i]
|
||||
result += int(left >= right)
|
||||
return result
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue