Friday, February 27, 2015

请教两个面试题

发信人: lsqlsqyy (月浸江心), 信区: JobHunting
标  题: 请教两个面试题
发信站: BBS 未名空间站 (Fri Feb 27 01:20:14 2015, 美东)

都是glassdoor上看到的面经:
1. You have a number of meetings (with their start and end times). You need
to schedule them using the minimum number of rooms. Return the list of
meetings in every room.

似乎可以把会议按个插入各个房间中。只要某会议与现有所有已安排的会议室都有冲突
,就安排出新会议室。如果没有冲突,就任意插入现有会议室。但这样做似乎没办法保
证使用房间最小化。

2. Implement two functions that assign/release unique id's from a pool.
Memory usage should be minimized and the
assign/release should be fast, even under high contention.

似乎可以用一个hashset来维护所有可用id,但这样用的内存太多。还有别的什么办法
可以保证assign/release快速,但内存消耗少吗?
--
※ 来源:·WWW 未名空间站 网址:mitbbs.com 移动:在应用商店搜索未名空间·[FROM: 169.]

http://www.mitbbs.com/article_t/JobHunting/32897835.html

No comments:

Post a Comment