FastPrepSmallest Number After Removing k Digits
Problems/Smallest Number After Removing k Digits

Smallest Number After Removing k Digits

Adobe logoAdobe● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: You remove k digits from a number to make what is left as small as possible. A report from an engineering manager candidate in North 24 Parganas, India, who got no offer, names this task by its title. It sits next to an unnamed binary-tree problem. Both came in the opening round in January 2022. In that call, only the applicant's camera was on even though video had been planned, with no briefing beforehand. No limits, edge rules or examples are given.

The rules are those of the named task. Remove exactly k digits and keep the rest in order. Drop leading zeros, and return "0" when nothing is left. We chose these limits: 1 to 5000 digits, and k from 0 to the length. We wrote new examples.

Our version is about 90% the same as the reported question.

You are given a non-negative whole number as a string num and an integer k. Remove exactly k digits from num, keeping the other digits in their original order, so that the number left is as small as possible. Return that number as a string.

Drop any leading zeros from the result. If no digits are left, or only zeros are left, return "0".

Function

smallestAfterRemoval(num: String, k: int) → String

Examples

Example 1

num = "7364019"k = 3return = "3019"

Remove 7, then 6 and 4 (each is larger than the digit after it) to keep 3, 0, 1, 9. The kept digits read 3019, which is the smallest result.

Example 2

num = "50082"k = 1return = "82"

Removing the leading 5 leaves 0082. Leading zeros are dropped, so the answer is 82.

Example 3

num = "468"k = 3return = "0"

All three digits are removed. Nothing is left, so the answer is 0.

Constraints

  • 1 <= num.length <= 5000
  • num consists of digits only and has no leading zeros, except when it is "0" itself.
  • 0 <= k <= num.length

More Adobe Phone Screen questions

  • Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
  • All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
  • Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
  • Binary Tree Level-Order Traversal by LevelsPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026
  • Count Occurrences in a Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
  • Count Pairs with Absolute Difference KPHONE SCREEN · Seen Jul 2026
  • Count Subsets with Sum KPHONE SCREEN · Seen Jul 2026
  • Numbers with Exactly Three DivisorsPHONE SCREEN · Seen Jul 2026
  • Sum of Even Nodes on a Path in a Numbered Binary TreePHONE SCREEN · Seen Jul 2026
  • Largest Value in Every Sliding WindowPHONE SCREEN · Seen Jul 2026

Similar questions at other companies

  • Remove K DigitsProcol · PHONE SCREEN
  • Minimum Removal for Balanced ParenthesesMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Largest Number After Removing K DigitsGoogle · PHONE SCREENGoogle interview questions
  • Minimum Remove to Make Valid ParenthesesBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Remove Duplicate Letters for the Largest ResultAmazon · PHONE SCREEN
  • Lexicographically Largest Distinct-Letter SubsequenceNavan · PHONE SCREENNavan interview questions
  • Substring RemovalJP Morgan Chase · OAJP Morgan Chase interview questions
  • Remove K DigitsThe D.E. Shaw Group · ONSITE INTERVIEWThe D.E. Shaw Group interview questions
  • Remove K DigitsMorgan Stanley · ONSITE INTERVIEWMorgan Stanley interview questions
  • Modify the StringYahoo · OAYahoo interview questions

Interview reports that mention this question

  • Adobe Frontend and QA Interviews: 14 Experiences (Part 6 of 6)

Adobe interview experiences

  • Adobe Web, QA, DevOps, ML Roles: 13 Experiences (Part 3 of 3)
  • Adobe SWE Interviews, Level Unknown: 25 Experiences (Part 2 of 3)
  • Adobe Interviews, Level Unknown: 38 Experiences (Part 1 of 3)
  • Adobe New Grad MTS Interview Questions: 7 Experiences
  • Adobe ML/Research Intern Interviews: 12 Experiences (Part 4 of 4)
All Adobe interview questionsSee Adobe hiring insights
Saved
class Solution {
    public String smallestAfterRemoval(String num, int k) {
        // Write your code here.
    }
}
Checking account…