1432. Max Difference You Can Get From Changing an Integer
https://leetcode.com/problems/max-difference-you-can-get-from-changing-an-integer
Description
You are given an integer num
. You will apply the following steps exactly two times:
Pick a digit
x (0 <= x <= 9)
.Pick another digit
y (0 <= y <= 9)
. The digity
can be equal tox
.Replace all the occurrences of
x
in the decimal representation ofnum
byy
.The new integer cannot have any leading zeros, also the new integer cannot be 0.
Let a
and b
be the results of applying the operations to num
the first and second times, respectively.
Return the max difference between a
and b
.
Example 1:
Example 2:
Example 3:
Example 4:
Example 5:
Constraints:
1 <= num <= 10^8
ac
Previous1431. Kids With the Greatest Number of CandiesNext1433. Check If a String Can Break Another String
Last updated