335. Self Crossing
一道数学题,考虑一条边被cross的两种情况,然后依次顺延边。
class Solution(object):
def isSelfCrossing(self, x):
"""
:type x: List[int]
:rtype: bool
"""
b = c = d = e = 0
for a in x:
if d >= b > 0 and (a >= c or (a >= c-e >= 0 and f >= d-b)):
return True
b, c, d, e, f = a, b, c, d, e
return False
网友评论