Startup VO 面试真题解析:Implement get_available_slots(raw_slots) 预约时段合并与校验

47次阅读
没有评论

Part 1 – Parse and Validate: Remove slots with missing fields, invalid ISO timestamps, or durations other than exactly 10 minutes.

Part 2 – Aggregate: Group consecutive valid 10-minute slots from the same provider and appointment type into bookable 30-minute blocks.

Overall: Implement get_available_slots(raw_slots) to return clean, valid, and bookable appointment availability without assuming the input is sorted.

这道题考察的是对预约时段数据的清洗、校验与合并。需要先过滤掉字段缺失、时间格式非法、以及时长不是 10 分钟的记录,再把同一 provider 和同一 appointment type 下连续的 10 分钟时段合并成可预订的 30 分钟块。由于输入不保证有序,通常需要先按时间排序,再线性扫描判断相邻时段是否连续,从而构建出最终可用的 availability 结果。

正文完
 0