Hmm here is a thought.

In the given number, check the second digit from the left.

if it is the maximum, find the digit that is the next greater digit from
the left most digit.
append it to the start and append all the other numbers in sorted order.

if the second from left isn't the largest, find the next digit that is
greater than the last digit and swap places with it.

On Mon, Dec 5, 2011 at 11:05 PM, raushan kumar <[email protected]>wrote:

> Given a number,find the next higher number using the same digits in the
> number.
> eg: 15432  :: 21345
>        14532
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Anup Ghatage

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to