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, 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 function
 
 
  Regards,
  Adi Srikanth.
  Mob No 9887233349
  Personal Pages: adisrikanth.co.nr
 
 
  On Fri, Sep 30, 2011 at 9:43 PM, Devesh Mittal
  devesh.vey...@gmail.comwrote:
 
  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 value pairs?
 
  --
  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.
 
 
   --
  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.
 
 
  --
  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.
 
 


 --
 Somnath Singh

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



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



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 duplicates at 2nd index(i) and 5th index(j), so
in the original array pick the elements from 3(i+1) to 5(j) which are the
  required elements , if there are no duplicates then u wont have sub array
with sum 0.

-Thanks


On Thu, Oct 20, 2011 at 1:54 AM, Ankur Garg ankurga...@gmail.com wrote:

 {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 use extra space also for the same


 Brute Force will do it in O(n^2). Any better way

 I was thinking DP but couldnt find proper sub-problems and even if we do
 cudnt figure out lesser than O(n^2) :(

 Any suggestions?

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


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



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.

so start index = 3 + 1 = 4;
last index = 6;

By set or treeMap we can solve it in O(nlogn) and by hashMap we can solve it
in O(n).

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



[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 use extra space also for the same


Brute Force will do it in O(n^2). Any better way

I was thinking DP but couldnt find proper sub-problems and even if we do
cudnt figure out lesser than O(n^2) :(

Any suggestions?

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



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



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 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



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



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



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 value pairs?

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


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



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 PM, Devesh Mittal devesh.vey...@gmail.comwrote:

 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 value pairs?

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


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


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



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 function


 Regards,
 Adi Srikanth.
 Mob No 9887233349
 Personal Pages: adisrikanth.co.nr


 On Fri, Sep 30, 2011 at 9:43 PM, Devesh Mittal
 devesh.vey...@gmail.comwrote:

 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 value pairs?

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


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


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




-- 
Somnath Singh

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



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



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



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




-- 
Best,
T Anand Karthik,

Contact number: +91-9571552652

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



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



 --
 Best,
 T Anand Karthik,

 Contact number: +91-9571552652

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



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



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)
 {
 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.com wrote:

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



 --
 Best,
 T Anand Karthik,

 Contact number: +91-9571552652

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



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


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



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:

 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.com wrote:

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



 --
 Best,
 T Anand Karthik,

 Contact number: +91-9571552652

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



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


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



[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 recurrence . I cant get it :(


Ankur

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



[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 them.
Given: n - no. of lines
a[i] b[i] c[i] - i th line.
X Y - Point
Output
A[i] B[i] C[i]
A[j] B[j] C[j]
such that the point X,Y is between them.

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



[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, 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.



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


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