알고리즘 - 큰 수 만들기

Coaspe·2021년 4월 1일
0

algorithm

목록 보기
1/10
def solution(number, k):
    stack = [number[0]]
    for num in number[1:]:
        while len(stack) > 0 and stack[-1] < num and k > 0:
            k -= 1
            stack.pop()
        stack.append(num)
    if k != 0:
        stack = stack[:-k]
    return ''.join(stack)
profile
https://github.com/Coaspe

0개의 댓글