/*// Definition for an Interval.class Interval {public: int start; int end; Interval() {} Interval(int _start, int _end) { start = _start; end = _end; }};*/classSolution {public:vector<Interval*> employeeFreeTime(vector<vector<Interval*>> schedule) { // Put all intervals together vector<Interval*> intervals;for(auto& emp: schedule) {for(auto& interv: emp) {intervals.push_back(interv); } } // Sort all intervals by start timesort(intervals.begin(),intervals.end(), [] (constInterval* a,constInterval* b) {returna->start <b->start; }); // Start finding free time vector<Interval*> res; Interval* cur =intervals[0];for(int i =1; i <intervals.size(); ++i) { Interval* next =intervals[i]; // no overlap, add free timeif(cur->end <next->start) {res.push_back(newInterval(cur->end,next->start)); cur = next; }else { cur = (cur->end <next->end) ? next : cur; } }return res; }};