[알고리즘] (프로그래머스) 예산

이용찬·2022년 1월 1일
0

알고리즘

목록 보기
18/31
post-thumbnail

문제
(프로그래머스) 예산

Python 풀이

def solution(d, budget):
    s = sorted(d)
    temp = []
    
    for i in range(len(s)):
        if sum(temp) < budget:
            temp.append(s[i])

    if sum(temp) > budget:
        temp = temp[:-1]

    return len(temp)
profile
안녕하세요. 클래식을 즐기는 개발자, 이용찬입니다.

0개의 댓글