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

Stats:

CreatedJul 4, 2015
PublishedJul 4, 2015
Warriors Trained118701
Total Skips20734
Total Code Submissions523001
Total Times Completed39314
JavaScript Completions11497
Python Completions15760
Ruby Completions1170
C# Completions2900
CoffeeScript Completions32
Java Completions3516
Kotlin Completions349
Rust Completions504
Haskell Completions246
C Completions935
Swift Completions253
Go Completions549
TypeScript Completions855
Julia Completions45
Crystal Completions16
Groovy Completions24
PHP Completions439
VB Completions16
COBOL Completions10
C++ Completions1193
Scala Completions17
Total Stars4877
% of votes with a positive feedback rating93% of 4581
Total "Very Satisfied" Votes4021
Total "Somewhat Satisfied" Votes468
Total "Not Satisfied" Votes92
Ad
Contributors
  • GiacomoSorbi Avatar
  • jhoffner Avatar
  • joh_pot Avatar
  • g964 Avatar
  • Unnamed Avatar
  • anter69 Avatar
  • Chrono79 Avatar
  • imjasonmiller Avatar
  • kazk Avatar
  • user5036852 Avatar
  • docgunthrop Avatar
  • JohanWiltink Avatar
  • Firefly2002 Avatar
  • Voile Avatar
  • Awesome A.D. Avatar
  • hobovsky Avatar
  • akvptp Avatar
  • OpenByte Avatar
  • jaeheonshim Avatar
  • TeoChrist Avatar
  • user8436785 Avatar
  • chrismatic Avatar
  • dfhwze Avatar
  • Just4FunCoder Avatar
  • KayleighWasTaken Avatar
  • Ryanlie Avatar
Ad