programmers | Lv1. ์˜ˆ์‚ฐ [Python]

yeonkยท2022๋…„ 2์›” 24์ผ
0

algorithm

๋ชฉ๋ก ๋ณด๊ธฐ
42/88
post-thumbnail

๐Ÿ’ก Python 3






๐Ÿ”— ๋ฌธ์ œ

์˜ˆ์‚ฐ [Link]






๐Ÿ’ป ์ฝ”๋“œ

def solution(d, b):
    d.sort()
    result = 0
    for c in d:
        if c <= b:
            result += 1
            b -= c
        else:
            break
    return result






๐Ÿ’ฅ ๋‹ค๋ฅธ ์‚ฌ๋žŒ ์ฝ”๋“œ

def solution(d, budget):
    d.sort()
    while budget < sum(d):
        d.pop()
    return len(d)

0๊ฐœ์˜ ๋Œ“๊ธ€