Find the maximum number of intersections lines
Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article
Given an N horizontal line segments are arranged on the X-axis of a 2D plane. The start and end point of each line segment is given in an Nx2 matrix lines, the task is to find the maximum number of intersections possible of any vertical line with the given N line segments.Examples:Input: N = 4, lines = {{1, 3}, {2, 3}, {1, 2}, {4, 4}}Output: 3Explanation: A vertical line at X = 2 passes through {1, 3}, {2, 3}, {1, 2}, ie three of the…