Careercup - Microsoft面试题 - 5700293077499904

时间:2023-03-09 00:19:23
Careercup - Microsoft面试题 - 5700293077499904

2014-05-12 00:02

题目链接

原题:

For a given map (ie Bing map) given longitude/latitude/ how would you design the system so that when map longitudeDelta/latitdueDelta changed you add additional pins on map for regions that was not previously cover.
In another word, how would you design it to avoid getting and displaying duplicated pins

题目:如果地图上坐标发生了变化,如何避免重复标记地点。(题目愣是没看懂。)

解法:哈希吗?既然坐标是会变化的,那么用自增id或者其他和位置无关的值来作为哈希键值,这样就可以避免重复标记了。

代码:

 // http://www.careercup.com/question?id=5700293077499904
Answer:
A location on the map may change, thus using the pair of <latitude, longitude> to be the unique id is not a good id.
Maybe using an auto-increment id is better.
A HashMap<int, Coordinate> which maps the auto-increment id to the coordinate will allow us to change the coordinates as necessary.
By the way, what kind of knowledge are these questions try to test? IQ, experience or inspiration?