Remove K Digits

Given a string representing a non-negative integer and an integer k, return the smallest possible integer after removing k digits from the number.

Constraints

  • 1 <= k <= num.length <= 10^5
  • num consists of only digits.
  • num does not have any leading zeros except for the zero itself.
Saving… · 2 lines
class Solution:
def removeKDigits(self, num: str, k: int) -> str:
Console

Click Run to execute sample tests.