Re: [閒聊] 每日leetcode
看板Marginalman作者DJYOSHITAKA (franchouchouISBEST)時間1年前 (2024/03/19 00:08)推噓0(0推 0噓 1→)留言1則, 1人參與討論串58/1548 (看更多)
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;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.137.247.129 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1710778129.A.114.html
→
03/19 00:09,
1年前
, 1F
03/19 00:09, 1F
討論串 (同標題文章)
完整討論串 (本文為第 58 之 1548 篇):