Skip to content

Latest commit

 

History

History
30 lines (18 loc) · 700 Bytes

README.md

File metadata and controls

30 lines (18 loc) · 700 Bytes

Kata: Next bigger number with the same digits

Summary

This kata is from coderwars.

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

Thought & Solution

First let's see how to compare 2 numbers.

Coderwars answer