[面试题] Find next higher number with same digits

Find next higher number with same digits. 

Example 1 : if num = 25468, o/p = 25486 
Example 2 : if num = 21765, o/p = 25167 
Example 3 : If num = 54321, o/p = 54321 (cause it's not possible to gen a higher num than tiz with given digits ).

 

Google的面试题,实际上就是next_permutation

你可能感兴趣的:(number)