本质上是看一组区间数组中的相交数组的个数。

static const auto io_sync_off = []() {
    // turn off sync
    std::ios::sync_with_stdio(false);
    // untie in/out streams
    std::cin.tie(nullptr);
    return nullptr;
}
();
class Solution {
  public:
    int minmumNumberOfHost(int n, vector<vector<int> >& startEnd) {
        vector<int> sortStart(n), sortEnd(n);
        for (int i = 0; i < n; i++) {
            sortStart[i] = startEnd[i][0];
            sortEnd[i] = startEnd[i][1];
        }
        sort(sortStart.begin(), sortStart.end());
        sort(sortEnd.begin(), sortEnd.end());
        int count = 0;
        for (int i = 0, j = 0; i < n; i++) {
            if (sortStart[i] >= sortEnd[j]) {
                j++;
            } else {
                count++;
            }
        }
        return count;
    }
};