美文网首页
8.19 - hard - 69

8.19 - hard - 69

作者: 健时总向乱中忙 | 来源:发表于2017-08-20 03:33 被阅读0次

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

相关文章

  • 8.19 - hard - 69

    335. Self Crossing 一道数学题,考虑一条边被cross的两种情况,然后依次顺延边。

  • 8.19 - hard - 70

    336. Palindrome Pairs 基本想出来是怎么做,只是一上来就想去优化,结果想的有点乱,其实最好的方...

  • 8.19 - hard - 65

    321. Create Maximum Number 这题的想法其实比较简单。首先分情况,针对两个数组取k个数,可...

  • 8.19 - hard - 64

    317 . Shortest Distance from All Buildings 典型的BFS的题目,BFS可...

  • 8.19 - hard - 66

    327. Count of Range Sum 中午请人吃饭,结果吃多了,好困,有点坐不动了。这题有segment...

  • 8.19 - hard - 67

    329. Longest Increasing Path in a Matrix 九章算法班里讲过的一道题,用记忆...

  • 8.19 - hard - 71

    340. Longest Substring with At Most K Distinct Characters...

  • 8.19 - hard - 68

    330. Patching Array 又是一道greedy的题目

  • 手绘05

    景观手绘, 8.18 8.19

  • 刷题

    8.19 530+15+356

网友评论

      本文标题:8.19 - hard - 69

      本文链接:https://www.haomeiwen.com/subject/howxdxtx.html