Warmup Section
Imagine you have a robot that sends status messages that humans will read in real time.
The raw messages are hard to read for a human because there are often many messages produced in short periods of time. One idea to make them more readable is to remove the duplicate messages over a 10-second window.
Design and implement a program to hide duplicates of any message that has already been displayed within the past 10 seconds.
Example Messages Received, with Timestamps:
10 solar panel activated
11 low battery warning
12 tire one: low air pressure
13 solar panel activated
14 low battery warning
21 solar panel activated
35 solar panel activated
Example Messages Shown to User:
10 solar panel activated
11 low battery warning
12 tire one: low air pressure
21 solar panel activated
35 solar panel activated
Updated Requirement Section
From experience operating the robot, users have determined there is a bug in the robot and duplicate messages are not to be trusted at all. Duplicate messages should be completely removed from the output if they occur within 10 seconds.
Design and implement a program to completely remove duplicate messages.
这题让你处理机器人的实时消息流,需要在 10 秒窗口内做消息去重 :
✅ 第一部分:
只要某条消息在过去 10 秒内已经展示过,就 不再展示 。
✅ 第二部分(更严格):
如果某条消息在 10 秒内出现重复,那么该消息的 所有出现(包括第一次)都要完全删除 ,因为这种重复代表机器人故障。
VOprep 团队长期陪同学员实战各类大厂 OA 与 VO,包括 OpenAI、Google、Amazon、Citadel、SIG 等,提供实时答案助攻、远程陪练与面试节奏提醒,帮助大家在关键时刻不卡壳。
如果你也在准备 Stripe 或类似工程向公司,可以了解一下我们的定制助攻方案——从编程面到系统设计,全程护航上岸。