2025-08-21 14:41:49 +0000 UTC

Points That Intersect With Cars

Code

class Solution:
    def numberOfPoints(self, nums: List[List[int]]) -> int:
        line = [0] * 102
        points_on_line = 0
        for start, end in nums:
            line[start] += 1
            line[end + 1] -= 1
        for i in range(1, 102):
            line[i] += line[i - 1]
            if line[i] != 0:
                points_on_line += 1
        return points_on_line