由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 问个近期亚麻高频题目
相关主题
G onsite面经兼求内推latest interview questions
问个算法题7求指点一个G家题
大家看看我哪道题做错了?看似很简单的一个BST问题但就是错了!
问两道onsite题目做过amazon OA的说说如何准备
请教一个面试题咨询一个system design 小细节问题
Amazon(5)问个string combination的问题
Java 面试关于map 和set问个常见算法题的变形
Apple 电面设计题- consistent between key-value store and database问个java hashcode的题
相关话题的讨论汇总
话题: vector话题: pageid话题: visited话题: log话题: page
进入JobHunting版参与讨论
1 (共1页)
g*****i
发帖数: 91
1
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
发帖数: 1093
2
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

g*****i
发帖数: 91
3
谢谢!
第一问可以避免排序吗? 感觉复杂度很高啊

the

【在 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.

p*****2
发帖数: 21240
4

排序nlogn,不排序n
不过一般这样的文件可能已经排好续了
如果用Clojure的话,一行代码应该可以搞定。

【在 g*****i 的大作中提到】
: 谢谢!
: 第一问可以避免排序吗? 感觉复杂度很高啊
:
: the

g*****i
发帖数: 91
5
in last 30 mins
我的理解是和当前时间比,所以维护一个hashmap>就可以吧,
每读一行看时间是不是和当前时间差超过30分钟,如果不是,就把page_id放到hashset
里。
二爷请指教一下...

【在 p*****2 的大作中提到】
:
: 排序nlogn,不排序n
: 不过一般这样的文件可能已经排好续了
: 如果用Clojure的话,一行代码应该可以搞定。

p*****2
发帖数: 21240
6

hashset
没看过原题,不过感觉这样就可以了。

【在 g*****i 的大作中提到】
: in last 30 mins
: 我的理解是和当前时间比,所以维护一个hashmap>就可以吧,
: 每读一行看时间是不是和当前时间差超过30分钟,如果不是,就把page_id放到hashset
: 里。
: 二爷请指教一下...

1 (共1页)
进入JobHunting版参与讨论
相关主题
问个java hashcode的题请教一个面试题
再问个算法题……Amazon(5)
问一道算法题Java 面试关于map 和set
问个Java的HashSet.contains的问题Apple 电面设计题- consistent between key-value store and database
G onsite面经兼求内推latest interview questions
问个算法题7求指点一个G家题
大家看看我哪道题做错了?看似很简单的一个BST问题但就是错了!
问两道onsite题目做过amazon OA的说说如何准备
相关话题的讨论汇总
话题: vector话题: pageid话题: visited话题: log话题: page