4 kyu
Next bigger number with the same digits
1,169 of 39,288GiacomoSorbi
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 | 118657 |
Total Skips | 20722 |
Total Code Submissions | 522838 |
Total Times Completed | 39288 |
JavaScript Completions | 11487 |
Python Completions | 15749 |
Ruby Completions | 1169 |
C# Completions | 2897 |
CoffeeScript Completions | 31 |
Java Completions | 3514 |
Kotlin Completions | 347 |
Rust Completions | 503 |
Haskell Completions | 245 |
C Completions | 933 |
Swift Completions | 252 |
Go Completions | 548 |
TypeScript Completions | 854 |
Julia Completions | 44 |
Crystal Completions | 15 |
Groovy Completions | 23 |
PHP Completions | 437 |
VB Completions | 15 |
COBOL Completions | 9 |
C++ Completions | 1191 |
Scala Completions | 16 |
Total Stars | 4876 |
% of votes with a positive feedback rating | 93% of 4579 |
Total "Very Satisfied" Votes | 4019 |
Total "Somewhat Satisfied" Votes | 468 |
Total "Not Satisfied" Votes | 92 |