4 kyu
Next bigger number with the same digits
11,497 of 39,314GiacomoSorbi
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 | 118701 |
Total Skips | 20734 |
Total Code Submissions | 523001 |
Total Times Completed | 39314 |
JavaScript Completions | 11497 |
Python Completions | 15760 |
Ruby Completions | 1170 |
C# Completions | 2900 |
CoffeeScript Completions | 32 |
Java Completions | 3516 |
Kotlin Completions | 349 |
Rust Completions | 504 |
Haskell Completions | 246 |
C Completions | 935 |
Swift Completions | 253 |
Go Completions | 549 |
TypeScript Completions | 855 |
Julia Completions | 45 |
Crystal Completions | 16 |
Groovy Completions | 24 |
PHP Completions | 439 |
VB Completions | 16 |
COBOL Completions | 10 |
C++ Completions | 1193 |
Scala Completions | 17 |
Total Stars | 4877 |
% of votes with a positive feedback rating | 93% of 4581 |
Total "Very Satisfied" Votes | 4021 |
Total "Somewhat Satisfied" Votes | 468 |
Total "Not Satisfied" Votes | 92 |