4 kyu
Next bigger number with the same digits
11,502 of 39,352GiacomoSorbi
Description:
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
Strings
Refactoring
Similar Kata:
Stats:
Created | Jul 4, 2015 |
Published | Jul 4, 2015 |
Warriors Trained | 118846 |
Total Skips | 20748 |
Total Code Submissions | 523183 |
Total Times Completed | 39352 |
JavaScript Completions | 11502 |
Python Completions | 15780 |
Ruby Completions | 1170 |
C# Completions | 2900 |
CoffeeScript Completions | 32 |
Java Completions | 3516 |
Kotlin Completions | 349 |
Rust Completions | 504 |
Haskell Completions | 246 |
C Completions | 936 |
Swift Completions | 253 |
Go Completions | 551 |
TypeScript Completions | 858 |
Julia Completions | 45 |
Crystal Completions | 16 |
Groovy Completions | 24 |
PHP Completions | 440 |
VB Completions | 16 |
COBOL Completions | 10 |
C++ Completions | 1201 |
Scala Completions | 17 |
Total Stars | 4880 |
% of votes with a positive feedback rating | 93% of 4585 |
Total "Very Satisfied" Votes | 4024 |
Total "Somewhat Satisfied" Votes | 469 |
Total "Not Satisfied" Votes | 92 |