@Lucifer..

i thnk for 14532..ur ans wud be..21354..but it shu..21345..
instread of reversing those..we have to sort them

On Tue, Dec 6, 2011 at 4:13 PM, Lucifer <sourabhd2...@gmail.com> wrote:

> @payel and anurag.. The algo that i have given is the same one that is
> used by "next_permutation".. And yes, its returns the next higher
> permutation.. In case ur input already points to the largest number
> then it will return the smaller number...
> On Dec 6, 12:38 pm, payel roy <smithpa...@gmail.com> wrote:
> > @anurag, does the vector's next permutation return next higher
> > element?
> >
> > On Dec 6, 8:10 am, Anurag Sharma <anuragvic...@gmail.com> wrote:
> >
> >
> >
> >
> >
> >
> >
> > > In context of C++
> >
> > >    1. Populate the digits of the given number in a vector V
> > >    2. call next_permutation() on V
> > >    3. print the vector [?]
> >
> > > Thanks,
> > > Anurag Sharma
> > > +91-8712218874
> >
> > > On Tue, Dec 6, 2011 at 2:23 AM, sourabh <sourabhd2...@gmail.com>
> wrote:
> > > > This problem is a direct implication of "next_permutation" defined
> in C
> > > > ++ STL algorithms.
> >
> > > > 1) From the end, keep decrementing till A[i] < A[i+1]..
> > > > 2) Now, find the closest element , greater than equal, to A[i] in A[i
> > > > +1 ... n]. Say, the index of the found element is "j".
> > > > 3) Swap (A[i], A[j])
> > > > 4) Reverse array A[i+1 .. n]
> >
> > > > On Dec 6, 12:37 am, Anup Ghatage <ghat...@gmail.com> wrote:
> > > > > 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 <
> > > > raushan.vns2...@gmail.com>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 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.
> >
> > > > > --
> > > > > 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 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.
> >
> > >  330.gif
> > > < 1KViewDownload- Hide quoted text -
> >
> > > - Show quoted text -
>
> --
> 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.
>
>


-- 
*Dheeraj Sharma*

-- 
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