Search
⌘K

Leetcode 352. Data Stream as Disjoint Intervals

Maintain a dynamic set of disjoint, sorted intervals that summarize all integers seen from a stream, merging intervals when a new value is adjacent to or overlaps existing ones. The challenge is to support many addNum operations and occasional getIntervals efficiently, especially when frequent merges keep the number of intervals small relative to the stream size.

Asked at:

Meta


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Late October, 2024

Meta

Mid-level

Implement a data structure to store integer intervals and perform two operations: storeInterval(int x, int y) to store an interval [x,y], and findNumber(int x) to check if a number x exists in any stored interval

Comments

Your account is free and you can post anonymously if you choose.