摘要:
# -*- coding:utf-8 -*- class Solution: def GetUglyNumber_Solution(self, index): # write code here if index < 1 : return 0 """ # 思路1:先判断是否为丑数,是丑数的基础上co... 阅读全文
posted @ 2019-08-12 11:27
lililili——
阅读(179)
评论(0)
推荐(0)
摘要:
# -*- coding:utf-8 -*- class Solution: def MoreThanHalfNum_Solution(self, numbers): # write code here """ # 方法1 # 时间复杂度:O(n) 空间复杂度:O(n) # 构造2个list,一个存储不相同的元素,一个存储不相同元素出现的次数 newArray = list(set(numbers 阅读全文
posted @ 2019-08-12 10:16
lililili——
阅读(141)
评论(0)
推荐(0)
摘要:
# -*- coding:utf-8 -*- class Solution: def NumberOf1(self, n): # write code here # 通过bin()可以直接将正数转为01二进制,而负数经过bin()转换得到的是带有“-”符号的字符串 # 针对负数,我们那他和32位1做与运算 if n < 0: n = n&0xFFFFFFFF count = 0 for i in 阅读全文
posted @ 2019-08-12 09:09
lililili——
阅读(180)
评论(0)
推荐(0)

浙公网安备 33010602011771号