Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Create a graph with <code>n + 4</code> vertices.
Vertices 0 to <code>n - 1</code> represent the circles, vertex <code>n</code> represents upper edge, vertex <code>n + 1</code> represents right edge, vertex <code>n + 2</code> represents lower edge, and vertex <code>n + 3</code> represents left edge.
Add an edge between these vertices if they intersect or touch.
Answer will be <code>false</code> when any of two sides left-right, left-bottom, right-top or top-bottom are reachable using the edges.