Bloomberg LP | Graduate Software Engineer | March 2020 [Reject]
Anonymous User
564

I was asked to implement getbrowserhistory() and geturl() functionality.
geturl() - > records the url visisted
proposed solution -> record the url in an unordered map, with url as key and freq and timestamp as value
getbrowserhistory() - > It must display the urls visited based on frequency of visit, if the frequency of visit is same then it must display on the basis of timestamp. The recently entered url must be always displayed first.
eg-> if visit is BBC->Google->facebook, it should display facebook->google->BBC
if visit is BBC-> BBC->Google->facebook, it should display facebook-> BBC->Google
proposed solution - > 1. convert map to vector 2. sort the vector based on freq and timestamp 3. display the urls
proposed an improvement -> to reduce the sort again and again we can use an ordered_map, since ordered_map stores in sorted order (couldn't implement this)

Comments (1)