Practice Maximum Difference by Remapping a Digit
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Create a maximum and a minimum independently from num. For each, choose one digit and replace all its occurrences by one chosen digit, possibly the same digit. Leading zeros are allowed in the result. Return the maximum obtainable numeric value minus the minimum.
Source: Maximum Difference by Remapping a Digit on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
num = 11891
Output
99009
# Example 2
Input
num = 90
Output
99
Constraints
1 <= num <= 10^8
Related LeetCode Problems
Practice more problems similar to Maximum Difference by Remapping a Digit.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.