Re: [algogeeks] Amazon : Find popular cost

2012-06-10 Thread Akshat Sapra
Here, we can use hashmap and use an extra variable max_till_now that will keep track of maximum element occured to us till now while updating. Time complexity of solution will be O(n) max_till_now = 0; for ( int i = 0; i < arr.size(); i++ ) { hashmap[arr[i]] += 1; if ( hashmap[a

Re: [algogeeks] Amazon : Find popular cost

2012-05-31 Thread atul anand
here find popular post means to find most repeated costso we can use combination of max-heap and hashtable. hashtable is required to keep track for distinct cost. so if cost is not present in hashtable then add it to the hashtable and then add it to the Max-heap with counter value =1...then h

[algogeeks] Amazon : Find popular cost

2012-05-31 Thread g4ur4v
How to find popular cost of the books, say book1 $10 book2 $20 book3 $40 book4 $50 book5 $10 book6 $20 http://www.careercup.com/question?id=13720752 -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, se