Re: [algogeeks] Amazon interview Question

2013-02-12 Thread Pralay Biswas
Guys, Why can't we simply use a hashset for both the questions. hash the arr[i] and the frequencies in the hash map in the first pass. Then iterate over the array to find the first arr[i] whose freq is 1 in the hash map. For second part, keep a count and find the kth element in the array whose

Re: [algogeeks] Amazon interview Question

2013-02-12 Thread Sadhan Sood
first problem can be solved using a fixed sized array if we know the range of numbers or a hash table with an appropriate hash function and it is O(N) for time and space as some solutions above already mentioned this. for the second problem, I don't think heap is the right data structure which is

Re: [algogeeks] Amazon interview Question

2013-02-12 Thread sourabh jain
One solution for the 2nd question can be LinkedHashMap (linked list + hashmap) . Store the integer in linked list in the order of occurrence in stream and make an entry in hashmap on first occurence. Delete the integer entry from linked list on 2nd occurence and replace the reference with some

[algogeeks] Threaded binary Trees

2013-02-12 Thread ghost
*What are the applications of threaded binary Trees apart from morris traversal ?* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email to

[algogeeks] Amazon Interview Questions

2013-02-12 Thread Pratik Mehta
Hi All, I need ur help in solving few questions. Would you please help me out *BY GIVING THE ALGORITHM AND THE LOGIC BEHIND IT and it's DEEP EXPLANATION IF POSSIBLE?* * * *a. Kadane’s Algo.* * * *b. Linked-list intersection point.* * [A tree with only parent pointer, how to find LCA?] * *

Re: [algogeeks] Re: Amazon Interview Question

2013-02-12 Thread Mohanabalan D B
can use counting sort On Sun, Jul 15, 2012 at 6:37 PM, santosh thota santoshthot...@gmail.comwrote: If we can retrieve ith prime efficiently, we can do the following... 1.maintain a prod=1, start from 1st element, say a[0]=n find n th prime 2.check if (prod% (ith_prime * ith_prime )==0) then

Re: [algogeeks] Amazon interview Question

2013-02-12 Thread rashmi i
Hey Pralay, Sorry, if I have missed any point.Why would we need to map the frequencies when the second problem can be solved by simply keeping a count and comparing the index values that have been already mapped. On Fri, Feb 8, 2013 at 11:19 AM, sourabh jain wsour...@gmail.com wrote: One

[algogeeks] Please take 3 minutes to help change the world

2013-02-12 Thread Manikanta Babu
Hi, I've just learned about the water crisis and would be grateful if you could spend a few minutes to help solve it: https://waterforward.charitywater.org/GSkEnwJl Thanks, Manikanta -- the charity: water team WaterForward, 387 Tehama Street, San Francisco, CA 94103, USA. Click here to