国产xxxx99真实实拍_久久不雅视频_高清韩国a级特黄毛片_嗯老师别我我受不了了小说

資訊專欄INFORMATION COLUMN

leetcode-846-Hand of Straights

xiguadada / 3172人閱讀

摘要:題意分出組連續的個元素的數組思路比較簡單,直接循環刪除連續的數組,如此循環反復。

題意:分出n組連續的W個元素的數組
思路:比較簡單,直接循環刪除連續的數組,如此while循環反復。
class Solution(object):
    def isNStraightHand(self, hand, W):
        # c = collections.Counter(hand)
        hand.sort()
        print(hand)
        while hand:
            try:
                start=hand[0]
                for i in range(W):
                    hand.remove(start+i)
            except Exception as e:
                return False
        return True
if __name__=="__main__":
    # hand = [1, 2, 3, 6, 2, 3, 4, 7, 8]
    # W = 3
    # hand = [1, 2, 3, 4, 5]
    # W = 4
    hand=[1,2,3,4,5,6]
    W=2

    st=Solution()
    out=st.isNStraightHand(hand,W)
    print(out)

文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規行為,您可以聯系管理員刪除。

轉載請注明本文地址:http://specialneedsforspecialkids.com/yun/42371.html

相關文章

  • [LeetCode] 846. Hand of Straights

    Problem Alice has a hand of cards, given as an array of integers. Now she wants to rearrange the cards into groups so that each group is size W, and consists of W consecutive cards. Return true if and...

    vslam 評論0 收藏0
  • The Power of Ten – Rules for Developing Safety Cri

    摘要:探測器的代碼就是寫的,真厲害 New Horizon 探測器的代碼就是 JPL 寫的,真厲害 http://pixelscommander.com/wp-content/uploads/2014/12/P10.pdf Gerard J. Holzmann NASA/JPL Laboratory for Reliable Software Pasadena, CA 91109 Mo...

    Muninn 評論0 收藏0

發表評論

0條評論

最新活動
閱讀需要支付1元查看
<