z*********5 发帖数: 3 | 1 最近在准备面试刷版上面经,下面几道题想了好久不知道应该如何考虑,希望版上大牛
们可以不吝赐教。。。。
1.Design a Message store system (in-memory storage) [seq_id, len, data]
chunk, 原帖地址:http://www.mitbbs.com/article_t/JobHunting/32578885.html
这题不知道应该注意的是什么?开一个循环数组+hashmap的话可以按seq_id 得到data,
maintain数组头和尾,内存满的时候把最早的覆盖。 如果还要求得到seq_id是某个区
间内的data,是不是可以考虑用类似于B Tree建index的方式来按顺序遍历各个seq_id?
2.Multiple threads can publish and receive each other's message: whenever a
thread publishes a message, all the other threads can receive and print out
that message; if multiple message get published, the messages should be
queued or whatever recorded and other threads can print out the message one
by one; no published message should be missed by any other threads.
原贴:http://www.mitbbs.com/article_t/JobHunting/32547841.html
这题跪了。。希望各位大牛可以指点一下. |
|