Distinct Digits
Time limit1sMemory limit1024 MB
Given l and r up to 10^5, the task finds any number in the range whose digits are all different, or reports -1.
- Level
Easy2 of 10
- Topics
- Brute force, Math
- Solved
- No attempts yet
Problem
You are given two integers and . Find an integer that satisfies the following conditions.
- .
- All digits of are different.
If there are multiple answers, print any of them.
Input
The first line contains two integers and ().
Output
If an answer exists, print any of them. Otherwise, print .
Notes
In the first example, is one possible answer. The number is not valid, because the digit appears more than once.
In the second example, there is no valid answer.