Package g0301_0400.s0335_self_crossing
Class Solution
-
- All Implemented Interfaces:
public final class Solution
335 - Self Crossing\.
Hard
You are given an array of integers
distance
.You start at point
(0,0)
on an X-Y plane and you movedistance[0]
meters to the north, thendistance[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, andfalse
if it does not.Example 1:
Input: distance = 2,1,1,2
Output: true
Example 2:
Input: distance = 1,2,3,4
Output: false
Example 3:
Input: distance = 1,1,1,1
Output: true
Constraints:
<code>1 <= distance.length <= 10<sup>5</sup></code>
<code>1 <= distancei<= 10<sup>5</sup></code>
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final Boolean
isSelfCrossing(IntArray x)
-
-
Method Detail
-
isSelfCrossing
final Boolean isSelfCrossing(IntArray x)
-
-
-
-