Skip to content

Practice Remove Digit From Number to Maximize Result

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#2259
LeetCode Problem

Remove Digit From Number to Maximize Result

Problem Statement

You are given a string number representing a positive integer and a character digit. Return the resulting string after removing exactly one occurrence of digit from number such that the value of the resulting string in decimal form is maximized. The test cases are generated such that digit occurs at least once in number.

Source: Remove Digit From Number to Maximize Result on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
number = "123", digit = "3"
Output
"12"

# Example 2

Input
number = "1231", digit = "1"
Output
"231"

# Example 3

Input
number = "551", digit = "5"
Output
"51"

Constraints

2 <= number.length <= 100
number consists of digits from '1' to '9'.
digit is a digit from '1' to '9'.
digit occurs at least once in number.

Related LeetCode Problems

Practice more problems similar to Remove Digit From Number to Maximize Result.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.