Given the list, you would never want to decrement the last element as you
want it to be the maximum.
so either retain or remove the last element
Lets consider the Minimum cost among the sequence i to j as Cost[i..j]
So if you remove the element j, you add j to the cost
Cost[i..j] = Min{
This seems longest increasing subsequence problem to me..
Thanks,
Anurag
On Mon, Apr 25, 2011 at 9:31 PM, snehal jain learner@gmail.com wrote:
few eg
input
4 7 12 3 1
output 4 7 12
cost: 4 by removing 3 n 1
eg 2
6 3 5 7 12 4
o/p 3 3 5 7 12
cost 7 by decrementing 6 by 3 and
@snehal jain
4 9 8 7 8
o/p 4 7 7 7 8
cost 3 by decrementing 9 n 8
Yes, now question is clear but your last example is incorrect.
4 9 8 7 8
o/p 4 8 8 8 8
cost 2 = decrementing (9 to 8) + incrementing (7 to 8)
--
You received this message because you are subscribed to the Google Groups
@above
you cant increment
On Tue, Apr 26, 2011 at 3:48 PM, Naveen Agrawal nav.coo...@gmail.comwrote:
@snehal jain
4 9 8 7 8
o/p 4 7 7 7 8
cost 3 by decrementing 9 n 8
Yes, now question is clear but your last example is incorrect.
4 9 8 7 8
o/p 4 8 8 8 8
cost 2 = decrementing (9 to
I don't understand your example. If the input has only one 3, and
the output has more than one, you have not sorted the elements. Do you
mean alter the elements to make the array non-decreasing?
Don
On Apr 25, 4:21 am, snehal jain learner@gmail.com wrote:
Given n elements, sort the elements.
just tell me
what is input and what will the output. atleast 3 example
--
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
few eg
input
4 7 12 3 1
output 4 7 12
cost: 4 by removing 3 n 1
eg 2
6 3 5 7 12 4
o/p 3 3 5 7 12
cost 7 by decrementing 6 by 3 and removing 4
eg 3
4 9 8 7 8
o/p 4 7 7 7 8
cost 3 by decrementing 9 n 8
i hope its clear now..
On Mon, Apr 25, 2011 at 9:16 PM, hary rathor harry.rat...@gmail.com