problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
leetcode::non_overlapping_intervals::Solution类 参考

#include <leetcode.h>

静态 Public 成员函数

static int eraseOverlapIntervals (vector< vector< int > > &intervals)
 

详细描述

在文件 leetcode.h2654 行定义.

成员函数说明

◆ eraseOverlapIntervals()

int leetcode::non_overlapping_intervals::Solution::eraseOverlapIntervals ( vector< vector< int > > &  intervals)
static

在文件 leetcode.cpp7196 行定义.

7196 {
7197 if(intervals.empty()) {
7198 return 0;
7199 }
7200
7201 sort(intervals.begin(), intervals.end(), [](const auto &u, const auto &v) { return u[1] < v[1]; });
7202
7203 const int n = intervals.size();
7204 int right = intervals[0][1];
7205 int ans = 1;
7206 for(int i = 1; i < n; ++i) {
7207 if(intervals[i][0] >= right) {
7208 ++ans;
7209 right = intervals[i][1];
7210 }
7211 }
7212 return n - ans;
7213 }

引用了 acwing::acwing1929::right.

被这些函数引用 leetcode::non_overlapping_intervals::TEST().


该类的文档由以下文件生成: