본문 바로가기
알고리즘/소스코드

PROGRAMMERS 42885: 구명보트

by cjw.git 2021. 1. 5.

Link : programmers.co.kr/learn/courses/30/lessons/42885


Python

더보기
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
def solution(people, limit):
    people.sort(reverse=True)
    counter = 0
 
    s_tp = 0
    e_tp = len(people) - 1
    while e_tp - s_tp >= 0:
        if people[s_tp] + people[e_tp] <= limit:
            s_tp += 1
            e_tp -= 1
            counter += 1
        else:
            s_tp += 1
            counter += 1
    return counter
 
cs

FeedBack

  1.  

 

 

 

cjw.git@gmail.com

댓글