上一页 1 ··· 5 6 7 8 9 10 下一页
摘要: #-*- 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 阅读全文
posted @ 2016-10-12 17:00 火金队长 阅读(163) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*- class Solution(object): def containsDuplicate(self, nums): numsdic={} for num in nums: numsdic[num]=numsdic[num]+1 if num in nu 阅读全文
posted @ 2016-10-12 16:59 火金队长 阅读(168) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*- # Definition for a binary tree node.# class TreeNode(object):# def __init__(self, x):# self.val = x# self.left = None# self.rig 阅读全文
posted @ 2016-10-12 16:59 火金队长 阅读(110) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*- # Definition for singly-linked list.# class ListNode(object):# def __init__(self, x):# self.val = x# self.next = None#Method1cl 阅读全文
posted @ 2016-10-12 16:58 火金队长 阅读(109) 评论(0) 推荐(0) 编辑
摘要: # Definition for singly-linked list.# class ListNode(object):# def __init__(self, x):# self.val = x# self.next = Noneclass Solution(object): def rever 阅读全文
posted @ 2016-10-12 16:57 火金队长 阅读(169) 评论(0) 推荐(0) 编辑
摘要: #-*- 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 阅读全文
posted @ 2016-10-12 16:56 火金队长 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2016-10-12 16:56 火金队长 阅读(202) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*-#给定一个整数N,那么N的阶乘N!末尾有多少个0? 比如:N=10,N!=3628800,N!的末尾有2个0。#所有的尾部的0可以看做都是2*5得来的,所以通过计算所有的因子中2和5的个数就可以知道尾部0的个数。#实际上,2的个数肯定是足够的,所以只需计算 阅读全文
posted @ 2016-10-12 16:55 火金队长 阅读(90) 评论(0) 推荐(0) 编辑
摘要: #Method 1import math class Solution(object): def majorityElement(self, nums): numsDic={} for num in nums: numsDic[num]=numsDic[nums]+1 if num in numsD 阅读全文
posted @ 2016-10-12 16:54 火金队长 阅读(184) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*- # ord(c) -> integer##Return the integer ordinal of a one-character string.##参数是一个ascii字符,返回值是对应的十进制整数class Solution(object): de 阅读全文
posted @ 2016-10-12 16:54 火金队长 阅读(156) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 下一页