Practice Self Crossing
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given an array of integers distance. You start at the point (0, 0) on an X-Y plane, and you move distance[0] meters to the north, then distance[1] meters to the west, distance[2] meters to the south, distance[3] meters to the east, and so on. In other words, after each move, your direction changes counter-clockwise. Return true if your path crosses itself or false if it does not.
Source: Self Crossing on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
distance = [2,1,1,2]
true
# Example 2
distance = [1,2,3,4]
false
# Example 3
distance = [1,1,1,2,1]
true
Constraints
Related LeetCode Problems
Practice more problems similar to Self Crossing.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.