@kartik : to some extent ur code is giving the right answer... btw
somehow check tis
let for example the no be 759854
then the next biggest no is 794558
btw ur program is giving 795854 which is undoubtedly wrong............
the code would give more appropriate result if u sort the numbers from
from i to n on meeting the condition of (a[i-1]<a[i])

On Thu, Sep 22, 2011 at 11:53 AM, Ramakant Sharma <ramakant...@gmail.com> wrote:
> starting from right find first digit less then right most digit,if no any
> digit is less,then move to next right most and compair ,,,,when found
> exchange those no,
> now sort the no.s up to that index of the given no which is exchanged:
> Ex:
> 43987723893239876
> first required sequence: 439877238932[3]987[6] swap these no
> 439877238932[6]{987[3]}
> now sort in decreasing orderĀ  439877238932[6]{3789} this is the required no
> ....correct me if any thing wrong
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Ratan Kumar
B. Tech
MNNIT,
Allahabad

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

Reply via email to