摘要: #-*- coding: UTF-8 -*-class Solution(object): def compareVersion(self, version1, version2): """ :type version1: str :type version2: str :rtype: int "" 阅读全文
posted @ 2016-11-13 19:31 火金队长 阅读(230) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*-#由于题目要求不返回任何值,修改原始列表,#因此不能直接将新生成的结果赋值给nums,这样只是将变量指向新的列表,原列表并没有修改。#需要将新生成的结果赋予给nums[:],才能够修改原始列表class Solution(object): def rota 阅读全文
posted @ 2016-11-13 19:30 火金队长 阅读(139) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*-#2147483648#在32位操作系统中,由于是二进制,#其能最大存储的数据是1111111111111111111111111111111。#正因为此,体现在windows或其他可视系统中的十进制应该为2147483647。#32位数的范围是 -214 阅读全文
posted @ 2016-11-13 19:30 火金队长 阅读(80) 评论(0) 推荐(0) 编辑
摘要: class Solution(object): def convertToTitle(self, n): """ :type n: int :rtype: str """ res='' while n>0: tmp=n n=(n-1)/26 res+=chr(65+(tmp-1)%26) retur 阅读全文
posted @ 2016-11-13 19:30 火金队长 阅读(190) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*-# The isBadVersion API is already defined for you.# @param version, an integer# @return a bool# def isBadVersion(version):class 阅读全文
posted @ 2016-11-13 19:29 火金队长 阅读(205) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*- class Solution(object): def isPalindrome(self, s): """ :type s: str :rtype: bool """ s=s.lower() if s==None:return False isPali 阅读全文
posted @ 2016-11-13 19:28 火金队长 阅读(170) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*- class MinStack(object): def __init__(self): """ initialize your data structure here. """ self.Stack=[] self.minStack=[] def pus 阅读全文
posted @ 2016-11-13 19:28 火金队长 阅读(190) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*- #ZigZag Conversion :之字型class Solution(object): def convert(self, s, numRows): """ :type s: str :type numRows: int :rtype: str " 阅读全文
posted @ 2016-11-13 19:27 火金队长 阅读(265) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*- #Hint1:#数字i,i的倍数一定不是质数,因此去掉i的倍数,例如5,5*1,5*2,5*3,5*4,5*5都不是质数,应该去掉#5*1,5*2,5*3,5*4 在数字1,2,3,4的时候都已经剔除过,因此数字5,应该从5*5开始#Hint2:#例:# 阅读全文
posted @ 2016-11-13 19:26 火金队长 阅读(237) 评论(0) 推荐(0) 编辑
摘要: #-*- coding: UTF-8 -*- #Tags:dynamic programming,sumRange(i,j)=sum(j)-sum(i-1)class NumArray(object): sums=[] def __init__(self, nums): """ initialize 阅读全文
posted @ 2016-11-13 19:26 火金队长 阅读(311) 评论(0) 推荐(0) 编辑