landscapemi的博客

# leetcode:Data Stream as Disjoint Intervals(352)

https://leetcode.com/problems/data-stream-as-disjoint-intervals/

class SummaryRanges {
public:
/** Initialize your data structure here. */
auto it = st.lower_bound(Interval(val, val));
int start = val, end = val;
if(it != st.begin() && (--it)->end+1 < val) it++;
while(it != st.end() && val+1 >= it->start && val-1 <= it->end)
{
start = min(start, it->start);
end = max(end, it->end);
it = st.erase(it);
}
st.insert(it,Interval(start, end));
}

vector<Interval> getIntervals() {
vector<Interval> result;
for(auto val: st) result.push_back(val);
return result;
}
private:
struct Cmp{
bool operator()(Interval a, Interval b) { return a.start < b.start; }
};
set<Interval, Cmp> st;
};  

#### LeetCode 352. Data Stream as Disjoint Intervals（数据流区间）

2016-06-16 01:11:36

#### LeetCode—352. Data Stream as Disjoint Intervals

2016-06-01 15:38:05

#### LeetCode #352: Data Stream as Disjoint Intervals

2016-09-17 22:12:55

#### leetcode.352. Data Stream as Disjoint Intervals

2016-06-03 21:41:49

#### [leetcode] 352. Data Stream as Disjoint Intervals 解题报告

2016-06-01 07:24:10

#### [leetcode-352]Data Stream as Disjoint Intervals(java)

2016-07-05 12:42:06

#### LeetCode题解——Data Stream as Disjoint Intervals

2016-06-02 09:07:12

#### 【leetcode】Data Stream as Disjoint Intervals

2016-06-01 21:47:47

#### Data Stream as Disjoint Intervals

2016-09-02 23:21:50