FastPrepLargest Number After Removing K Digits
Problems/Largest Number After Removing K Digits

Largest Number After Removing K Digits

Google logoGoogle● MediumNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report says this is a well-known remove-k-digits problem with the goal flipped: remove k digits to make the largest possible integer. It gives num=4902, k=2, result 92. We chose a string return, exact removal wording, how leading zeros are cleaned up, the signature, more examples, and the input limits. Our version is about 96% the same as the reported question.

Given a decimal string num and an integer k, remove exactly k digits while preserving the relative order of the remaining digits.

Return the largest possible remaining integer as a string. Remove leading zeroes from the result. If no digit remains or the result contains only zeroes, return "0".

Function

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

Examples

Example 1

num = "4902"k = 2return = "92"

Remove 4 and 0. The two digits left keep their order and form the largest number you can get, which is the answer.

Example 2

num = "1432219"k = 3return = "4329"

Remove the rest and keep the digits 4329, in their original order. No other choice of digits to keep gives a larger number, so that is the answer.

Example 3

num = "10"k = 2return = "0"

Both digits are removed, so no digit is left. The function returns zero as a string.

Constraints

  • 1 <= num.length <= 200000.
  • num contains only decimal digits.
  • 0 <= k <= num.length.

More Google Phone Screen questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Periodic-Color Binary Forest RootsPHONE SCREEN · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
  • Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
  • Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
  • Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Remove K DigitsProcol · PHONE SCREEN
  • Minimum Removal for Balanced ParenthesesMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Minimum Remove to Make Valid ParenthesesBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Smallest Number After Removing k DigitsAdobe · PHONE SCREENAdobe 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

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
  • Google Experienced SWE First Round and Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public String largestAfterRemovingKDigits(String num, int k) {
        // write your code here
    }
}
Checking account…