0335. Self Crossing

https://leetcode.com/problems/self-crossing

Description

You are given an array of integers distance.

You start at 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, and false if it does not.

Example 1:

Example 2:

Example 3:

Constraints:

  • 1 <= distance.length <= 105

  • 1 <= distance[i] <= 105

ac

Last updated

Was this helpful?