Skip to content

Latest commit

 

History

History
19 lines (14 loc) · 502 Bytes

Next bigger number with the same digits.md

File metadata and controls

19 lines (14 loc) · 502 Bytes

Next bigger number with the same digits

You have to create a function that takes a positive integer number and returns the next bigger number formed by the same digits:

nextBigger(12)==21
nextBigger(513)==531
nextBigger(2017)==2071

If no bigger number can be composed using those digits, return -1:

nextBigger(9)==-1
nextBigger(111)==-1
nextBigger(531)==-1

solution