Given a mapping of teams to their data access patterns, and a list of deleted data files, determine which teams are impacted.
Build a system that can:
- Parse team data relationships
- Identify affected teams when specific data files are deleted
- Generate an alert list of teams that need immediate notification
Input Format
The system will receive a JSON object containing:
teams: Dictionary mapping team names to their data access patternsdata_read: List of data paths the team reads fromdata_written: List of data paths the team writes to
deleted_data: List of data paths that were deleted
Output Format
Return a list of teams that need to be alerted, sorted alphabetically.
这道题的核心是根据团队的数据读写路径,判断哪些团队会受到已删除数据的影响。做法通常是先把每个团队的 <code>data_read</code> 和 <code>data_written</code> 统一整理成集合,再将删除的数据路径放入集合中进行匹配;只要某个团队的任一路径与删除列表有交集,就需要加入告警名单。由于最终要求按字母序输出,因此可以在收集完受影响团队后排序返回。整体更像一个集合查找与过滤问题,重点在于高效地判断路径是否命中,而不是复杂算法。