Uber | Onsite | Rectangle intersections | SDE2 | Banglore, India
Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2022-03-13Added By Anonymous
Source: Link
Company: Uber
Role: software engineer ii
Interview Stage: Onsite
Location: Banglore, India
Original Post Content:
Given a 2D plane, list of lines parallel to X-axis or Y-axis and list of rectangles (perimeter lines are parallel to either X-axis or Y-axis). Find the number of intersection points where these lines cut the rectangles.
For Example:-
We have been given Y coordinates for lines parallel X-axis -> 1, 2, 4, 19
and X coordinates for lines parallel to Y-axis -> 2, 5, 9
and there's 1 rectangle, given bottom left and top right coordinates as :-
Rectangle 1 -> ((1,3), (3,6))
Total number of intersection points are :- 4