Skip to content

Latest commit

 

History

History
18 lines (17 loc) · 498 Bytes

File metadata and controls

18 lines (17 loc) · 498 Bytes

Next bigger number with the same digits

4 kyu link to kata
my solution

Create a function that takes a positive integer and returns the next bigger number that can be formed by rearranging its digits. For example:

  12 ==> 21
 513 ==> 531
2017 ==> 2071

If the digits can't be rearranged to form a bigger number, return -1 (or nil in Swift, None in Rust):

  9 ==> -1
111 ==> -1
531 ==> -1