Problem
Ask
Submissions

Problem: Remove K Digits

Medium
30 min
Understand how to apply greedy algorithms to remove exactly k digits from a numeric string and form the smallest possible number. This lesson helps you grasp the problem constraints, develop a logical approach, and implement an efficient solution in Python.

Statement

Given a string, num, that represents a non-negative integer and an integer k, remove exactly k digits from num so that the remaining digits form the smallest possible number.

Constraints:

  • 11 \leq k \leq num.length 105\leq 10^5

  • num consists of only digits.

  • num does not have any leading zeros except for the zero itself.

Problem
Ask
Submissions

Problem: Remove K Digits

Medium
30 min
Understand how to apply greedy algorithms to remove exactly k digits from a numeric string and form the smallest possible number. This lesson helps you grasp the problem constraints, develop a logical approach, and implement an efficient solution in Python.

Statement

Given a string, num, that represents a non-negative integer and an integer k, remove exactly k digits from num so that the remaining digits form the smallest possible number.

Constraints:

  • 11 \leq k \leq num.length 105\leq 10^5

  • num consists of only digits.

  • num does not have any leading zeros except for the zero itself.