摘要: 给定一个非负整数 numRows,生成杨辉三角的前 numRows 行(第一个我写的,我越优化,效率越低,懵逼) class Solution(object): def generate1(self, numRows): """ :type numRows: int :rtype: List[Lis 阅读全文
posted @ 2021-01-27 16:45 楠海 阅读(62) 评论(0) 推荐(0)
摘要: 颠倒给定的 32 位无符号整数的二进制位(硬性拼字符串就是我的) class Solution: # @param n, an integer # @return an integer def reverseBits1(self, n): binary_ = lambda n: "" if n == 阅读全文
posted @ 2021-01-27 11:45 楠海 阅读(59) 评论(0) 推荐(0)
摘要: 两个整数之间的汉明距离指的是这两个数字对应二进制位不同的位置的数目。(主题思想就是取异或,之后与1取与) class Solution(object): def hammingDistance1(self, x, y): """ :type x: int :type y: int :rtype: i 阅读全文
posted @ 2021-01-27 09:49 楠海 阅读(51) 评论(0) 推荐(0)