Random coding challenges and my attempt at solving them
- Given a number, find the next possible biggest number by reusing the number's digits.
Input | Output |
---|---|
12 | 21 |
122 | 212 |
1234 | 1243 |
2017 | 2071 |
2071 | 2107 |
1234 | 1243 |
63842 | 64238 |
218765 | 251678 |
534976 | 536479 |
-
When a number does not have any next possible number, it returns -1 (e.g. 441 returns -1)
-
Invalid input strings throw an ArgumentException