Re: [algogeeks] Re: Directi interview question

2011-08-08 Thread shady
@DK can you please explain your solution, i couldn't understand... @all any alternate solution ? On Sun, Aug 7, 2011 at 11:02 PM, DK divyekap...@gmail.com wrote: This is a simple problem: 1. Understand that if you are selecting 2 petrol pumps, say P and Q with say another petrol pump R

Re: [algogeeks] Re: Directi interview question

2011-08-08 Thread Ankur Garg
I can think of this solution Put first elements in a max heap ..O(10) Now take 11 th element ..compare it with root of this max heap ..If less than root ignore ..else remove root and call max-heapify and put this element in right place Similarly do this for rest Complexity will be n+nlogk

Re: [algogeeks] Re: Directi interview question

2011-08-08 Thread Brijesh Upadhyay
Yeah..right..! u have to select continuous 10 petrol pumps , so just traverse through every set of 10 pumps with complexity of o(n). e.g. (1,10) (2,11) (3,12)(91 ,100) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this

[algogeeks] Re: Directi interview question

2011-08-07 Thread iama
I think you are missing some part of the question Are the petrol pumps placed uniformly? How many do we have to select exactly? (you have added a 'say' in the statement above. Is it upto the us to choose?) -- You received this message because you are subscribed to the Google Groups Algorithm

Re: [algogeeks] Re: Directi interview question

2011-08-07 Thread subramania jeeva
No.. They are not uniform.. They will give you distance between two adjacent stations.. Cheers ~ Jeeva ~ On Sun, Aug 7, 2011 at 9:13 PM, iama mailroo...@gmail.com wrote: I think you are missing some part of the question Are the petrol pumps placed uniformly? How many do we

Re: [algogeeks] Re: Directi interview question

2011-08-07 Thread Anuj Kumar
starting from each petrol pump binary search for the value of distance On Sun, Aug 7, 2011 at 9:15 PM, subramania jeeva subramaniaje...@gmail.comwrote: No.. They are not uniform.. They will give you distance between two adjacent stations.. Cheers ~ Jeeva ~ On Sun, Aug 7,

Re: [algogeeks] Re: Directi interview question

2011-08-07 Thread DK
This is a simple problem: 1. Understand that if you are selecting 2 petrol pumps, say P and Q with say another petrol pump R between them, then it is optimal to include R into the set of selected petrol pumps as the max-distance for the chosen pumps remains PQ but number of included petrol