Amazon Interview Question
Software Engineer / DevelopersI think since the types a book can be represented is limited, not a big no and will be known in advance. just have a datastructure which has book name and a map of type and count of times downloaded, also have apis for adding counts, getting most downloaded type etc.
You mite want to store these book data structures in the best search DS ( depends on what API's u need). I would recommend a trie of book names based on what i think will be needed( remember every book search shows similar books :P)
Hold the N books in a hash table and keep a max heap associated with each of the book. The formats available for the book will be the nodes for the max-heap.
- algooz June 22, 2008Each node of the heap will have a key associated with it and if the popularity of the format goes high so does the value of the key. and in a max-heap the node with highest key would be at the top.