You are given an array distance where each element represents how many units you walk in the current direction.
You begin at position (0, 0) facing north.
After every move, you rotate 90 degrees counter-clockwise (north → west → south → east → …).
Your task is to determine whether, during this sequence of moves, the path ever overlaps or intersects any segment you have already drawn.
Return true if the path intersects itself at least once; otherwise, return false.
Input: distance = [3, 3, 3, 2]
Output: false
Explanation:
The fourth move brings the path into a previous segment.
Input: distance = [1, 1, 2, 1, 1]
Output: true
Explanation:
The path loops back to a previously visited point.
Input: distance = [2, 3, 4, 5]
Output: false
Explanation:
No intersections occur; the path continues outward.
Accepted:
Submission: