Merge Anomaly Windows

Xem dạng PDF

Gửi bài giải

Điểm: 100,00
Giới hạn thời gian: 2.0s
Giới hạn bộ nhớ: 256M

Tác giả:
Dạng bài
Ngôn ngữ cho phép
Python

Task

Given n anomaly detection intervals [start, end] (inclusive timestamps), merge all overlapping or adjacent intervals and return the sorted merged list.

Two intervals are adjacent if start2 == end1 + 1 — consecutive timestamps count as one continuous anomaly window.

Input

  • Line 1: integer n
  • Lines 2 to n+1: start end (two ints per line)

Output

One merged interval per line: start end

Example

Input:

4
1 3
2 6
8 10
15 18

Output:

1 6
8 10
15 18

Scaffolding

def merge_windows(intervals: list[tuple]) -> list[tuple]: ...

Notes

Track E: stdlib only. Sort intervals by start time, then scan linearly. Merging anomaly windows is the post-processing step after threshold-based detection.


Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.