[面试题] 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

posted @ 2014-04-03 17:36  Eason Liu  阅读(221)  评论(0)    收藏  举报