처음 푼 문제는 시간 초과 문제가 있었다.
def solution(A):
# write your code in Python 3.6
dif = float('inf')
for p in range(1, len(A)):
first = sum(A[:p])
second = sum(A[p:])
dif = min(dif, abs(first-second))
return dif
def solution(A):
# write your code in Python 3.6
dif = float('inf')
first = 0
second = sum(A)
for p in range(len(A)-1):
first += A[p]
second -= A[p]
dif = min(dif, abs(first-second))
return dif