프로그래머스
def solution(triangle):
n = len(triangle)
for i in range(1, n):
for j in range(i+1):
if j==0:
triangle[i][j] += triangle[i-1][j]
elif j==i:
triangle[i][j] += triangle[i-1][j-1]
else:
triangle[i][j] += max(triangle[i-1][j-1],triangle[i-1][j])
answer = max(triangle[n-1])
return answer
def solution(people, limit):
answer = 0
people.sort()
left = 0
right = len(people)-1
while left<=right:
if people[left]+people[right] <=limit:
left+=1
right-=1
answer+=1
else:
right-=1
answer+=1
return answer
while True:
n = len(people)
if n==0:
break
if people[n-1] + people[0] <= limit:
people = people[1:n-1]
else:
people = people[:n-1]
answer+=1