'''In this question we are going to use stack to rmove k digits from the number to make it smaller'''


def removeKdig(nums,k):
    stack = []

    for num in nums:
        while k>0 and stack and stack[-1]>num:
            k-=1
            stack.pop()

        stack.append(num)

    if k>0:
        stack = stack[:-k]

    return ''.join(stack).lstrip('0') or '0'
2bcdaf483e4dfbd6c3d18582e19a62efd7cb331c
<mask token>

<mask token>


def removeKdig(nums, k):
    stack = []
    for num in nums:
        while k > 0 and stack and stack[-1] > num:
            k -= 1
            stack.pop()
        stack.append(num)
    if k > 0:
        stack = stack[:-k]
    return ''.join(stack).lstrip('0') or '0'

'''In this question we are going to use stack to rmove k digits from the number to make it smaller'''


def removeKdig(nums,k):
    stack = []

    for num in nums:
        while k>0 and stack and stack[-1]>num:
            k-=1
            stack.pop()

        stack.append(num)

    if k>0:
        stack = stack[:-k]

    return ''.join(stack).lstrip('0') or '0'