bool comp(const Interval& i1, const Interval& i2){

return i1.start<=i2.start;

}

class Solution {

public:

```
vector<Interval> merge(vector<Interval> &intervals) {
// IMPORTANT: Please reset any member data you declared, as
// the same Solution instance will be reused for each test case.
vector<Interval> re;
int le = intervals.size();
if(le==0) return re;
if(le==1) return intervals;
std::sort(intervals.begin(),intervals.end(),comp);
for(int i=0; i<le;)
{
int ss=intervals[i].start;
int ee = intervals[i].end;
i++;
while(i<le && intervals[i].start<=ee)
{
ee=intervals[i].end;
i++;
}
Interval ans(ss, ee);
re.push_back(ans);
}
return re;
}
```

};