가로 방향으로 긴 풍선 시작점과 끝점들이 담긴 2차원 정수형 벡터를 받는다
이 때 화살을 세로 방향으로 쏴서 모든 풍선을 터뜨릴 때,
화살을 가장 적게 쏘는 횟수를 구하는 문제
class Solution {
public:
static const int START = 0;
static const int END = 1;
int findMinArrowShots(vector<vector<int>>& points) {
sort(points.begin(), points.end(),
[] (const auto &lhs, const auto &rhs)
{
return (lhs[START] < rhs[START]);
});
int result{1};
int target{0};
for (int i = 1; i < points.size(); i++)
{
if (points[i][START] <= points[target][END])
{
if (points[i][END] < points[target][END])
{
points[target][END] = points[i][END];
}
continue;
}
target = i;
result++;
}
return result;
}
};