- Notifications
You must be signed in to change notification settings - Fork 86
Expand file tree
/
Copy pathbalanced-array.py
More file actions
Latest commit
24 lines (23 loc) · 675 Bytes
/
Copy pathbalanced-array.py
File metadata and controls
24 lines (23 loc) · 675 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
classSolution:
"""
@param sales: a integer array
@return: return a Integer
"""
defBalancedSalesArray(self, sales):
# write your code here
ls, rs= [], []
foriinsales:
ifnotls:
ls.append(i)
else:
ls.append(ls[-1] +i)
foriinrange(len(sales) -1, -1, -1):
ifnotrs:
rs.append(sales[i])
else:
rs.append(rs[-1] +sales[i])
foriinrange(len(sales)):
ifls[i] ==rs[len(sales) -i-1]:
returni
return-1
# easy: https://www.lintcode.com/problem/1793/