2022-03-27 18:35:17 +08:00
< p > You are given an array of integers < code > distance< / code > .< / p >
2023-12-09 18:42:21 +08:00
< p > You start at the point < code > (0, 0)< / code > on an < strong > X-Y plane,< / strong > and you move < code > distance[0]< / code > meters to the north, then < code > distance[1]< / code > meters to the west, < code > distance[2]< / code > meters to the south, < code > distance[3]< / code > meters to the east, and so on. In other words, after each move, your direction changes counter-clockwise.< / p >
2022-03-27 18:35:17 +08:00
2023-12-09 18:42:21 +08:00
< p > Return < code > true< / code > < em > if your path crosses itself or < / em > < code > false< / code > < em > if it does not< / em > .< / p >
2022-03-27 18:35:17 +08:00
< p > < / p >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 1:< / strong > < / p >
< img alt = "" src = "https://assets.leetcode.com/uploads/2022/12/21/11.jpg" style = "width: 400px; height: 413px;" / >
2022-03-27 18:35:17 +08:00
< pre >
< strong > Input:< / strong > distance = [2,1,1,2]
< strong > Output:< / strong > true
2023-12-09 18:42:21 +08:00
< strong > Explanation:< / strong > The path crosses itself at the point (0, 1).
2022-03-27 18:35:17 +08:00
< / pre >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 2:< / strong > < / p >
< img alt = "" src = "https://assets.leetcode.com/uploads/2022/12/21/22.jpg" style = "width: 400px; height: 413px;" / >
2022-03-27 18:35:17 +08:00
< pre >
< strong > Input:< / strong > distance = [1,2,3,4]
< strong > Output:< / strong > false
2023-12-09 18:42:21 +08:00
< strong > Explanation:< / strong > The path does not cross itself at any point.
2022-03-27 18:35:17 +08:00
< / pre >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 3:< / strong > < / p >
< img alt = "" src = "https://assets.leetcode.com/uploads/2022/12/21/33.jpg" style = "width: 400px; height: 413px;" / >
2022-03-27 18:35:17 +08:00
< pre >
2023-12-09 18:42:21 +08:00
< strong > Input:< / strong > distance = [1,1,1,2,1]
2022-03-27 18:35:17 +08:00
< strong > Output:< / strong > true
2023-12-09 18:42:21 +08:00
< strong > Explanation:< / strong > The path crosses itself at the point (0, 0).
2022-03-27 18:35:17 +08:00
< / pre >
< p > < / p >
< p > < strong > Constraints:< / strong > < / p >
< ul >
< li > < code > 1 < = distance.length < = 10< sup > 5< / sup > < / code > < / li >
< li > < code > 1 < = distance[i] < = 10< sup > 5< / sup > < / code > < / li >
< / ul >