프로그래머스/level 2

[프로그래머스] 구명보트

binaryJournalist 2021. 12. 20. 15:18
반응형

 

출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges

 

 

 

 

** Python

 

def solution(people, limit):
    answer = 0
    people.sort()
    start, end = 0, len(people) - 1
    while start <= end:
        answer += 1
        if people[start] + people[end] <= limit:
            start += 1
        end -= 1
    return answer

 

 

반응형