Amazon Interview Question
Software Development ManagersCountry: United States
Interview Type: In-Person
For a given list of keywords, we also need to perform intersection to gather the list of songs which better match the keywords. One can use the Sql Intersect or if the search entries are in memory (set. or hashtable), then iterate over the set or lookup into hashtable and increament the match count for each keyword appear in the song description(tags etc). gather the one which produces the higher count.
You'd need a mapping of keywords to songs
- confused_coder August 21, 2016Keywords can include popular phrases/lyrics from the song, artist name, album name, genre, etc
For example
bad -> bad blood, bad romance, taylor, swift, taylor swift, lady gaga, gaga, etc
something -> something about you, something in the way you move etc
You would also need a mapping of songs to key words
For example
bad blood -> taylor swift, 1989
something in the way you move -> ellie goulding, delirium etc
You could use these two hash tables to get a list of relevant results for a search keyword/phrase
You could also cache a list of recent search queries and results (for auto fill and fast data service), if needed
Categorized search can also be used, eg search by artist, song, album; this could use category specific tables for quick look up