Re: [algogeeks] amazon ques

2011-12-31 Thread Ashish Goel
the LL has to be a DLL as deletion would be a prob otherwise. Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Sat, Oct 1, 2011 at 9:42 AM, SAMM somnath.nit...@gmail.com wrote: Linked List + Hash table will serve the purpose in O(1). On 9/30/11,

Re: [algogeeks] Amazon Ques Suggest Algo

2011-10-20 Thread SUMANTH M
- Take another sum array which contains sums of original array at each index, here sum[0] = a[0]; sum[1] = a[0] + a[1] ;...sum[i]=a[0]+a[1]+...a[i]; - Traverse the sum array and search for duplicates. ex: a[] = {1,2,-4,-3, 6 ,-3}; s[] = { 1,3,-1,-4,2,-1 }; In the sum array we have

Re: [algogeeks] Amazon Ques Suggest Algo

2011-10-20 Thread anshu mishra
index = 0 1 2 3 4 5 6 ar = 0 1 2 -4 -3 6 -3 sumar = 0 1 3 -1 -4 2 -1 first index where we get the number which has already appeared in sumar will be the last index of sub array whose sum will be zero and (index of first apperance of this number + 1) in sumar will be the start index.

[algogeeks] Amazon Ques Suggest Algo

2011-10-19 Thread Ankur Garg
{You are given an unsorted array of integers. You have to find out the first sub array whose elements when added sum up to zero. eg:- int Array[] = {1,2,-4,-3, 6 ,-3.}Here sub array is -3,6,-3 bcos adding all these sum to zero. A sub array can be of size 2 to whole length of the array. You can

[algogeeks] Amazon Ques

2011-10-04 Thread Ankur Garg
Find out the smallest segment in a document containing all the given words. Desired Complexity is O nlogK ..n is the total no of words in the document and k is the number of input words -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post

Re: [algogeeks] amazon ques

2011-10-01 Thread manish kapur
@somnath...can u pls elaborate... he was looking for an elaborate ans... -- 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

Re: [algogeeks] amazon ques

2011-10-01 Thread manish kapur
@adi.. he gave a hint that space used should not b of order of range of numbers but should depend on how many numbers are inserted... eg..if range is say 1000...bt u entered only 5 nos -8,100,202,600,989. u can use space of order 5..and not 1000 -- You received this message because you are

[algogeeks] amazon ques

2011-09-30 Thread manish kapur
u have to perform following tasks in O(1) time 1.)insertion 2.)deletion 3.)searching no range of input numbers is given wat data structure will you use? if u use hashing wat will be the key and value pairs? -- You received this message because you are subscribed to the Google Groups Algorithm

Re: [algogeeks] amazon ques

2011-09-30 Thread Devesh Mittal
Fibonacci Heaps On Fri, Sep 30, 2011 at 9:14 PM, manish kapur manishkapur.n...@gmail.comwrote: u have to perform following tasks in O(1) time 1.)insertion 2.)deletion 3.)searching no range of input numbers is given wat data structure will you use? if u use hashing wat will be the key and

Re: [algogeeks] amazon ques

2011-09-30 Thread Adi Srikanth
if space complexity is not a constraint..u can use any kind of hashing and its function.depends on the kind of data we store..if its numbers go for square or simple linear function Regards, Adi Srikanth. Mob No 9887233349 Personal Pages: adisrikanth.co.nr On Fri, Sep 30, 2011 at 9:43

Re: [algogeeks] amazon ques

2011-09-30 Thread SAMM
Linked List + Hash table will serve the purpose in O(1). On 9/30/11, Adi Srikanth adisriika...@gmail.com wrote: if space complexity is not a constraint..u can use any kind of hashing and its function.depends on the kind of data we store..if its numbers go for square or simple linear

Re: [algogeeks] Amazon Ques

2011-09-28 Thread KARTHIKEYAN V.B.
reversing the linked list static void reverse(struct node** head_ref) { struct node* p=NULL; struct node* curr=*head_ref; struct node* q; while(curr!=NULL) { q=curr-next; curr-next=p; p=curr; curr=q; } *head_ref=p; } -- You received this message because you are subscribed to the Google Groups

[algogeeks] Amazon Ques

2011-09-27 Thread Ankur Garg
Print Reverse of linked list (dont reverse it) with only constant space. Recursion uses stack spaceO(n) ..so post some other solution .. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] Amazon Ques

2011-09-27 Thread anand karthik
Reverse it , print it and reverse it again. :-) On Wed, Sep 28, 2011 at 3:28 AM, Ankur Garg ankurga...@gmail.com wrote: Print Reverse of linked list (dont reverse it) with only constant space. Recursion uses stack spaceO(n) ..so post some other solution .. -- You received this message

Re: [algogeeks] Amazon Ques

2011-09-27 Thread rahul sharma
reverse(head) { if(head==NUll) { printf(head-info); return; } reverse(head-link) printf(head-info); } On Wed, Sep 28, 2011 at 4:39 AM, anand karthik anandkarthik@gmail.comwrote: Reverse it , print it and reverse it again. :-) On Wed, Sep 28, 2011 at 3:28 AM, Ankur Garg

Re: [algogeeks] Amazon Ques

2011-09-27 Thread sukran dhawan
@rahul if(head == null) return; u cant print head-info when head is null On Wed, Sep 28, 2011 at 8:20 AM, rahul sharma rahul23111...@gmail.comwrote: make sure that u ryt the syntax correct On Wed, Sep 28, 2011 at 8:18 AM, rahul sharma rahul23111...@gmail.comwrote: reverse(head) {

Re: [algogeeks] Amazon Ques

2011-09-27 Thread sukran dhawan
call function recursively when it is the last node, return the function calls and print it On Wed, Sep 28, 2011 at 8:20 AM, rahul sharma rahul23111...@gmail.comwrote: make sure that u ryt the syntax correct On Wed, Sep 28, 2011 at 8:18 AM, rahul sharma rahul23111...@gmail.comwrote:

[algogeeks] Amazon ques

2011-09-11 Thread Ankur Garg
given an array of size N containing only 0s and 1s return the length of the maximum sub array containing equal number of 0s and 1s Give a O(n) solution It has been asked before in this forum but no one has given a proper solution so m asking again May be we need DP here..But what will be the

[algogeeks] amazon ques :Online round

2011-08-25 Thread Ankur Garg
You are given n no. of lines in form of Ax + By = C, basically you are given A[i], b[i] and C[i] for line i. Lines are given in a way such that 0 = x[i] = 1 and y[i] y[i+1] for same X. Also, one point (x,y) is given too. Find out the two closest lines to the point such that the point is between

[algogeeks] Amazon Ques

2011-08-22 Thread Ankur Garg
Find the middle of the stack..(Time complexity should be minimum) Stack is not implemented as Linked List ...u have normal stack with push,pop and top How to do this ?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,

Re: [algogeeks] Amazon Ques

2011-08-22 Thread Shravan Kumar
Pop each element and en-queue it twice and de-queue it once. When stack is empty the front of the queue will be middle element. On Mon, Aug 22, 2011 at 4:01 PM, Ankur Garg ankurga...@gmail.com wrote: Find the middle of the stack..(Time complexity should be minimum) Stack is not implemented