Re: [algogeeks] minimum no. of clicks

2011-02-02 Thread saurabh gupta
@bittu consider 12112 does your solution say 2 clicks ? @srikar i don't think we can. On Tue, Feb 1, 2011 at 11:34 PM, Srikar srikar2...@gmail.com wrote: Could I sort it? Oh you mentioned that the original array could be destroyed. In that case, 1) Sort the array - O(nlogn) 2) loop

[algogeeks] minimum no. of clicks

2011-02-01 Thread snehal jain
You are given an array A of length N. You have to destroy it, given that you have the power to remove any continuous chunk of same numbers with 1 click. Thus the order in which you remove chunk matters. For example given {1, 2, 3, 1} normally it will take you 4 clicks to remove but if you first

Re: [algogeeks] minimum no. of clicks

2011-02-01 Thread Srikar
Could I sort it? Oh you mentioned that the original array could be destroyed. In that case, 1) Sort the array - O(nlogn) 2) loop through the array. if contiguous elements are same remove all of them in one click else remove only that element. - O(n) Time - O(nlogn) space - O(1) On Tue, Feb