FastPrepRemove K Digits
Problem · Stack

Remove K Digits

MediumAmazon logoAmazonINTERNONSITE INTERVIEW
See Amazon hiring insights

Problem statement

You are given a string num that represents a non-negative integer, and an integer k.

Remove exactly k digits from num so the remaining digits stay in their original relative order and form the smallest possible integer.

The problem statement continues
Pro

Examples

Example 1

num = "1432219"k = 3return = "1219"

Removing the digits 4, 3, and 2 from 1432219 leaves 1219, which is the smallest remaining integer.

FastPrep Pro
Reported in 1 Amazon interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 2 more worked examples, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week
CodePython 3
Run and Submit unlock with Pro
FastPrep Pro
Reported in 1 Amazon interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 2 more worked examples, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week