摘要:
def aa(nums): if not nums: return False left,right=0,len(nums)-1 mid=(left+right)/2 while left<mid<right: while not bb(nums[left]): left +=1 while ... 阅读全文
摘要:
class Solution: def aa(self,s): isAllowdot=True isAllowE=True for i in range(len(s)): if (s[i] in"+-" and i==0) or (s[i-1] in "eE" and i=len(s)-1 or s... 阅读全文
摘要:
class Solution: def match(self, s, pattern): if s == pattern: return True if len(pattern)>1 and pattern[1] == '*': if s and (s[0]==pattern[0] or patter... 阅读全文
摘要:
class ListNode(object): def __init__(self,x): self.val=x self.next=None class Link(object): def __init__(self,values=None): self.nodes=self.set_link(values) i... 阅读全文
摘要:
class ListNode(object): def __init__(self,x): self.val=x self.next=None def del_link(head,node): if head==node: del node if node.next==None: ... 阅读全文
摘要:
def aa(base,exponent): if base==0 and exponent>1) ret *=ret if exponent &1==1: ret *=base return ret print(aa(3,5)) #剑指offer python版 打印1到最大的n位数 def cc(n): b=aa(10,n) ... 阅读全文
摘要:
def aa(base,exponent): if base==0 and exponent>1) ret *=ret if exponent &1==1: ret *=base return ret print(aa(3,5)) 阅读全文
摘要:
def aa (n): if not n: return False ret=0 while n: ret +=1 n=n&n-1 return ret print(aa(38)) 阅读全文
摘要:
def rope_cut(length): # 最优解数组,当长度为0是为0,当长度为1是为1,当长度为2时为2,当长度大于3时,3就不能切开了,因为3>1*2,最优解数组为3 li=[0,1,2,3] if length==0:#当长度为0时,返回0 return 0 if length==1:#当长度为1时,返回1 return... 阅读全文
摘要:
class Solution: def judge(self, threshold, i, j): # sum(map(int, str(i) + str(j)))这一句简直精髓! 直接得到坐标位置的 位和! i,j是超过1位的数也可以完美解决! if sum(map(int, str(i) + str(j))) =0 and j>=0 and self.... 阅读全文