Good morning! Here's your coding interview problem for today.
This problem was asked by Facebook.
Suppose you are given two lists of n points, one list p1, p2, ..., pn on the line y = 0 and the other list q1, q2, ..., qn on the line y = 1. Imagine a set of n line segments connecting each point pi to qi. Write an algorithm to determine how many pairs of the line segments intersect.
Good morning! Here's your coding interview problem for today.
This problem was asked by Facebook.
Suppose you are given two lists of n points, one list
p1, p2, ..., pnon the line y = 0 and the other listq1, q2, ..., qnon the line y = 1. Imagine a set of n line segments connecting each point pi to qi. Write an algorithm to determine how many pairs of the line segments intersect.