Skip to content

Practice Points That Intersect With Cars

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#2848
LeetCode Problem

Points That Intersect With Cars

Problem Statement

You are given a 0-indexed 2D integer array nums representing the coordinates of the cars parking on a number line. For any index i, nums[i] = [starti, endi] where starti is the starting point of the ith car and endi is the ending point of the ith car. Return the number of integer points on the line that are covered with any part of a car.

Source: Points That Intersect With Cars on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [[3,6],[1,5],[4,7]]
Output
7

# Example 2

Input
nums = [[1,3],[5,8]]
Output
7

Constraints

1 <= nums.length <= 100
nums[i].length == 2
1 <= starti <= endi <= 100

Related LeetCode Problems

Practice more problems similar to Points That Intersect With Cars.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.