Trains the technique from
LeetCode 3783Mirror Distance of an IntegerThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
Reading the digits of n in the opposite order gives another whole number, dropping any leading zeros that appear.
Return how far apart the two numbers are.
Example 1
Reading the digits the other way gives 3124, and 4213 less 3124 is 1089.
Example 2
The digits read backwards give 002, which is the number 2, so the gap is 198.
Example 3
The number reads the same either way, so the gap is nothing.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def mirror_distance(n: int) -> int:public int mirrorDistance(int n)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.