leetcode_335. Self Crossing ? 待解决

来源:互联网 发布:如何看待吴敦义 知乎 编辑:程序博客网 时间:2024/05/21 09:04

You are given an array x of n positive numbers. You start at point (0,0) and moves x[0] metres to the north, then x[1] metres to the west, x[2] metres to the south, x[3] metres to the east and so on. In other words, after each move your direction changes counter-clockwise.

Write a one-pass algorithm with O(1) extra space to determine, if your path crosses itself, or not.

提示:提交代码后,需要用简洁的语言解释一下代码思路~ 谢谢

历史题目和总结见公众号「每日一道算法题」

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

思路

原创粉丝点击