Day32

作者: wendy_要努力努力再努力 | 来源:发表于2017-12-22 23:32 被阅读0次

**还是没有恢复状态,我似乎都有点忘了现在人工智能的火热度,又好久没有用过deep了。

  1. Nim Game
    思路:像这种题就是找规律,有经验的人能更好的玩好脑筋急转弯。
class Solution(object):
    def canWinNim(self, n):
        """
        :type n: int
        :rtype: bool
        """
        if n % 4 == 0:
            return False
        return True

  1. Binary Number with Alternating Bits
    思路:判断二进制形式下的01是否交叉出现。
class Solution(object):
    def hasAlternatingBits(self, n):
        """
        :type n: int
        :rtype: bool
        """
        st = bin(n).replace('0b','')
        for i in range(len(st)-1):
            if st[i]== st[i+1]:
                return False
        return True

相关文章

网友评论

      本文标题:Day32

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