vector<vector<int>> merge(vector<vector<int>>& intervals) {
sort(intervals.begin(), intervals.end());
vector<vector<int>> result;
for (const auto& vec: intervals) {
if (result.empty() || result.back()[1] < vec[0]) {
result.push_back(vec);
}
else {
result.back()[1] = max(result.back()[1], vec[1]);
}
}
return result;
}