Class Solution

  • All Implemented Interfaces:

    
    public final class Solution
    
                        

    2848 - Points That Intersect With Cars\.

    Easy

    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, <code>numsi = start<sub>i</sub>, end<sub>i</sub></code> where <code>start<sub>i</sub></code> is the starting point of the <code>i<sup>th</sup></code> car and <code>end<sub>i</sub></code> is the ending point of the <code>i<sup>th</sup></code> car.

    Return the number of integer points on the line that are covered with any part of a car.

    Example 1:

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

    Output: 7

    Explanation: All the points from 1 to 7 intersect at least one car, therefore the answer would be 7.

    Example 2:

    Input: nums = \[\[1,3],5,8]

    Output: 7

    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.

    Constraints:

    • 1 &lt;= nums.length &lt;= 100

    • nums[i].length == 2

    • <code>1 <= start<sub>i</sub><= end<sub>i</sub><= 100</code>

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Solution()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Integer numberOfPoints(List<List<Integer>> nums)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait