给定一个以字符串表示的非负整数 num,移除这个数中的 k 位数字,使得剩下的数字最小。
class Solution:def removeKdigits(self, num: str, k: int) -> str:stack=[]remain_num=len(num)-kfor c in num:while k and stack and ord(stack[-1])>ord(c):stack.pop()k-=1stack.append(c)return ''.join(stack[:remain_num]).lstrip('0') or '0'