Determine whether a set of line segments forms one continuous, non-breaking line.
You are given several line segments drawn on a plane. Decide whether they can be viewed as one continuous line without gaps or breaks.
A valid continuous line means that the segments connect in a way that the whole figure is connected as a single chain or loop, with no isolated piece.
Return whether the drawn segments form a continuous line.
YES if the segments form one continuous line.NO.Example 1
Input
3 0 0 2 0 2 0 4 0 4 0 6 0
Output
YES
Explanation
All three segments touch end-to-end, so together they form one continuous line.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.