Skip to content

Practice Max Difference You Can Get From Changing an Integer

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

Medium#1432
LeetCode Problem

Max Difference You Can Get From Changing an Integer

Problem Statement

Independently create two results from the original positive integer num. For each result, choose decimal digits x and y, which may be equal, and replace every occurrence of x by y. Neither result may be zero or have a leading zero. Return the largest possible difference between the two results.

Source: Max Difference You Can Get From Changing an Integer on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
num = 555
Output
888

# Example 2

Input
num = 9
Output
8

Constraints

1 <= num <= 10^8

Related LeetCode Problems

Practice more problems similar to Max Difference You Can Get From Changing an Integer.

Review your practice with PhantomCodeAI

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