def solution(d, budget):
    result = 0
    d = sorted(d)
    
    for i in range(len(d)):
        result += d[i]
        if result > budget:
            answer = len(d[:i])
            break
            
    if result <= budget:
        answer = len(d)
    return answer

 

def solution(d, budget):
    d.sort()
    for i in range(len(d)):
        if sum(d) > budget:
            d.pop()
    return len(d)

+ Recent posts