3034. Points That Intersect With Cars
My accepted C++ solution to LeetCode problem 3034, Points That Intersect With Cars, running in 4ms.
- Difficulty: Easy
- C++
- Runtime 4ms
- Memory 30.3MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
C++
Accepted on LeetCode — runtime 4ms, memory 30.3MB, accepted 2025-12-27.
class Solution {
public:
int numberOfPoints(vector<vector<int>>& nums) {
unordered_set<int> points;
for (auto& car : nums) {
for (int i = car[0]; i <= car[1]; i++) {
points.insert(i);
}
}
return points.size();
}
};