Re: [閒聊] 每日leetcode

作者: DJYOSHITAKA (Evans)   2024-03-19 00:08:47
452. Minimum Number of Arrows to Burst Balloons
照區間尾巴排
然後射射射射射射射
想了一段時間
interval好難
int findMinArrowShots(vector<vector<int>>& points) {
auto comp = [](vector<int>& x, vector<int>& y){ return x[1] < y[1]; };
sort(points.begin(), points.end(), comp);
int ans = 1;
int cur_x = points[0][1];
for(int i=1; i<points.size(); i++)
{
if(points[i][0] > cur_x)
{
cur_x = points[i][1];
ans++;
}
}
return ans;
}
作者: sustainer123 (caster)   2024-03-19 00:09:00
大師

Links booklink

Contact Us: admin [ a t ] ucptt.com