Given a log file which consists of timestamp, customer ID, page id visited by that particular customer. Write a function to return all customers who have visited 5 unique pages in last 30 mins 这个题目最近看面经见得很多,还有类似的是这个: http://www.mitbbs.com/article_t/JobHunting/32644779.html
sort the log by timestamp read the log and insert the entry to map(5)> This is enough for this problem, whenever the vector reach size 5, push the result into the result vector For another problem, when read new entry, you need to pop_front and push_ back the new pageID in the tail of the mapped vector. at the same time, maintain a map(5), int counter> and the maximum counter value and page list.
【在 g*****i 的大作中提到】 : Given a log file which consists of timestamp, customer ID, page id visited : by that particular customer. Write a function to return all customers who : have visited 5 unique pages in last 30 mins : 这个题目最近看面经见得很多,还有类似的是这个: : http://www.mitbbs.com/article_t/JobHunting/32644779.html
【在 h****n 的大作中提到】 : sort the log by timestamp : read the log and insert the entry to map(5)> : This is enough for this problem, whenever the vector reach size 5, push the : result into the result vector : For another problem, when read new entry, you need to pop_front and push_ : back the new pageID in the tail of the mapped vector. : at the same time, maintain a map(5), int counter> and the : maximum counter value and page list.