Startup / VO OA 面试真题解析:Dict Bot(字符串解析与消息处理)

19次阅读
没有评论

Dict Bot

We are building a small chat bot that can receive messages and keep track of what everyone has said.

Given a sequence of messages, implement a function that processes each message and produces the corresponding bot outputs.

The bot should support the following message patterns:

  • A message indicating that a user says something.
  • A message indicating that a user is away.
  • A message indicating that a user returns and updates their away status.
  • A special message about meeting with Google Meet.
  • A special message about tacos and how many a user has.

The bot must store messages and update user states accordingly.

The exact formatting of bot outputs should match the problem requirements.

这道题本质上是一个字符串解析与状态维护题:需要按顺序处理聊天消息,不同的消息模式,并维护每个用户的在线 / 离开状态以及附加信息。实现时通常会用字典分别记录用户当前是否 away、最近的留言内容,以及像 taco 数量这样的统计值。难点在于把输入消息拆分成固定格式并正确匹配分支,输出时要严格遵守题目要求的文案格式。

正文完
 0