Given array of line segments (line between two points). Find can a line (infinite length) be drawn from origin(0,0) which does not intersect any of these lines segements.
line: p1(x1,y1) to p2(x2,y2)
Return type: True or False
Follow up:
Find if a line can be drawn passing through point (x,y) without intersecting any other line segments.
I solved it in O(n*logn) time complexcity with some help from interviewer.
Problem boils down to finding gaps in a list of pairs.
Algo:
Follow up soln:
Move origin to point given. (Shifiting origin)