亚马逊面试题:设计代客泊车系统(停车场系统设计 | 面向对象设计)

48次阅读
没有评论

I own a parking garage that provides valet parking service.

There are three types of parking spots:

  • small
  • medium
  • large

Cars also come in three sizes:

  • small
  • medium
  • large

Rules:

  • A small car can fit in any spot
  • A medium car can fit in medium or large spots
  • A large car can fit only in large spots

You receive a stream of parking events.
Each event is either:

  • "arrival" with a car size
  • "departure" with the same car size (the car leaves and frees its spot)

Your system must assign a valid spot on arrival and free the spot on departure.

Example input (conceptual):

(arrival, small)
(arrival, large)
(arrival, medium)
(departure, small)
(arrival, large)
...

You need to design a system (API + data structure) that correctly handles spot assignment and freeing while following the size rules.


维护 三类车位的可用数量
到达时按规则选择 能满足要求的最小车位
离开时根据记录的车位类型释放车位。
用映射记录每辆车分配到的车位类型。

VOprep 团队长期陪同学员实战各类大厂 OA 与 VO,包括 Google、Amazon、Citadel、SIG 等,提供实时答案助攻、远程陪练与面试节奏提醒,帮助大家在关键时刻不卡壳。
如果你也在准备公司,可以了解一下我们的定制助攻方案——从编程面到系统设计,全程护航上岸。

正文完
 0