LeetCode solutions

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

Read the problem on LeetCode View on GitHub

C++

Accepted on LeetCode — runtime 4ms, memory 30.3MB, accepted 2025-12-27.

cpp
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();
    }
};

Source