category-wise-problems

contains category wise problems(data structures, competitive) of popular platforms.

View the Project on GitHub mayankdutta/category-wise-problems

56. Merge Intervals

implementation ```cpp vector<pair<int, int>> arr; vector<vector> ans; for (const auto& i: intervals) arr.push_back({i[0], i[1]}); sort(arr.begin(), arr.end()); int curr = 0; for (int i = 1; i < arr.size(); i++) { if (arr[i].first <= arr[curr].second) { arr[curr].second = max(arr[i].second, arr[curr].second); arr[i].first = -1; arr[i].second = -1; } else { curr = i; } } for (const auto& i: arr) if (i.first != -1) ans.push_back({i.first, i.second}); return ans; } ``` </details>