摘要:
#-*- coding: UTF-8 -*- class Solution(object): def isPowerOfTwo(self, n): if(n<=0): return False if(n==1): return True while True: tuple=divmod(n,2) i 阅读全文
摘要:
#-*- coding: UTF-8 -*- class Solution(object): def containsDuplicate(self, nums): numsdic={} for num in nums: numsdic[num]=numsdic[num]+1 if num in nu 阅读全文
摘要:
#-*- coding: UTF-8 -*- # Definition for a binary tree node.# class TreeNode(object):# def __init__(self, x):# self.val = x# self.left = None# self.rig 阅读全文
摘要:
#-*- coding: UTF-8 -*- # Definition for singly-linked list.# class ListNode(object):# def __init__(self, x):# self.val = x# self.next = None#Method1cl 阅读全文
摘要:
# Definition for singly-linked list.# class ListNode(object):# def __init__(self, x):# self.val = x# self.next = Noneclass Solution(object): def rever 阅读全文
摘要:
#-*- coding: UTF-8 -*- class Solution(object): def hammingWeight(self, n): if n<=0:return n mid=[] while True: if n==0:break n,mod=divmod(n,2) mid.app 阅读全文
摘要:
class Solution(object): def rob(self, nums): """ :type nums: List[int] :rtype: int """ n=len(nums) if n==0: return 0 if n==1: return nums[0] i=2 maxin 阅读全文
摘要:
#-*- coding: UTF-8 -*-#给定一个整数N,那么N的阶乘N!末尾有多少个0? 比如:N=10,N!=3628800,N!的末尾有2个0。#所有的尾部的0可以看做都是2*5得来的,所以通过计算所有的因子中2和5的个数就可以知道尾部0的个数。#实际上,2的个数肯定是足够的,所以只需计算 阅读全文
摘要:
#-*- coding: UTF-8 -*- # ord(c) -> integer##Return the integer ordinal of a one-character string.##参数是一个ascii字符,返回值是对应的十进制整数class Solution(object): de 阅读全文
摘要:
#Method 1import math class Solution(object): def majorityElement(self, nums): numsDic={} for num in nums: numsDic[num]=numsDic[nums]+1 if num in numsD 阅读全文