Data Engineering Hours With Experts Coding Challenge!
For a given number, return the next largest number that can be created by rearranging that number's digits.
If no larger number can be created, return -1
Example inputs/outputs are shown below:
Input | Output |
---|---|
12 | 21 |
21 | -1 |
12345678 | 12345687 |
34535762 | 34536257 |
45590051 | 45590105 |
987654321 | -1 |
You can create your solution in Java, Scala, or Python. Some files and tests have been created for you as a starting point. Instructions for importing the Java and Scala projects into Intellij are included.
- Validating command line arguments - you can just assume each program takes 1 argument which is always a valid number