2848. Points That Intersect With Cars Easy

@problem@discussion
#Array#Hash Table#Prefix Sum



1/**
2 * [2848] Points That Intersect With Cars
3 *
4 * 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 i^th car and endi is the ending point of the i^th car.
5 * Return the number of integer points on the line that are covered with any part of a car.
6 *  
7 * <strong class="example">Example 1:
8 * 
9 * Input: nums = [[3,6],[1,5],[4,7]]
10 * Output: 7
11 * Explanation: All the points from 1 to 7 intersect at least one car, therefore the answer would be 7.
12 * 
13 * <strong class="example">Example 2:
14 * 
15 * Input: nums = [[1,3],[5,8]]
16 * Output: 7
17 * Explanation: Points intersecting at least one car are 1, 2, 3, 5, 6, 7, 8. There are a total of 7 points, therefore the answer would be 7.
18 * 
19 *  
20 * Constraints:
21 * 
22 * 	1 <= nums.length <= 100
23 * 	nums[i].length == 2
24 * 	<font face="monospace">1 <= starti <= endi <= 100</font>
25 * 
26 */
27pub struct Solution {}
28
29// problem: https://leetcode.com/problems/points-that-intersect-with-cars/
30// discuss: https://leetcode.com/problems/points-that-intersect-with-cars/discuss/?currentPage=1&orderBy=most_votes&query=
31
32// submission codes start here
33
34impl Solution {
35    pub fn number_of_points(nums: Vec<Vec<i32>>) -> i32 {
36        0
37    }
38}
39
40// submission codes end
41
42#[cfg(test)]
43mod tests {
44    use super::*;
45
46    #[test]
47    fn test_2848() {
48    }
49}
50


Back
© 2025 bowen.ge All Rights Reserved.