上一页 1 2 3 4 5 6 ··· 9 下一页
摘要: from collections import deque class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Tree(object): def __init__(self)... 阅读全文
posted @ 2018-10-30 10:12 findtruth123 阅读(295) 评论(0) 推荐(0) 编辑
摘要: from collections import deque class TreeNode(object): """ 二叉树结点定义 """ def __init__(self, x): self.val = x self.left = None self.right = None class Tree(obj... 阅读全文
posted @ 2018-10-30 09:28 findtruth123 阅读(242) 评论(0) 推荐(0) 编辑
摘要: def str_to_int(string): if not string: # 空字符返回异常 raise Exception('string cannot be None', string) flag = 0 # 用来表示第一个字符是否为+、- ret = 0 # 结果 for k, s in enumerate(string): ... 阅读全文
posted @ 2018-10-29 17:31 findtruth123 阅读(279) 评论(1) 推荐(0) 编辑
摘要: def aa(A): n=len(A) B=[1 for i in range(n)] for i in range(n): for j in range(n): if i !=j: B[i] *=A[j] return B print(aa([1,2,3]... 阅读全文
posted @ 2018-10-29 16:51 findtruth123 阅读(211) 评论(0) 推荐(0) 编辑
摘要: def add(n,m): while m: summ=n^m carry=(n&m)<<1 m=carry n=summ return n print(add(3,4)) 阅读全文
posted @ 2018-10-29 16:31 findtruth123 阅读(273) 评论(0) 推荐(0) 编辑
摘要: def aa(n): return sum(range(n+1)) print(aa(9)) 阅读全文
posted @ 2018-10-29 16:12 findtruth123 阅读(301) 评论(0) 推荐(0) 编辑
摘要: def aa(nums): a,b=0,1 ret=[] leng=len(nums) for i in range(leng-1): for j in range(i+1,leng): ret.append(nums[j]-nums[i]) retur... 阅读全文
posted @ 2018-10-29 16:08 findtruth123 阅读(405) 评论(0) 推荐(0) 编辑
摘要: def aa(n,m): ret=0 if n==1: return 0 for i in range(2,n+1): ret= (m+ret)%i return ret print(aa(5,3)) 阅读全文
posted @ 2018-10-29 15:37 findtruth123 阅读(450) 评论(0) 推荐(0) 编辑
摘要: import random def is_continus(nums, k): data = [random.choice(nums) for _ in range(k)] data.sort() print data zero = data.count(0) small, big = zero, zero + 1 while big 1: ... 阅读全文
posted @ 2018-10-29 15:34 findtruth123 阅读(250) 评论(0) 推荐(0) 编辑
摘要: import random def aa(n): q=0 while n: m=random.randint(1,6) q +=m n -=1 return q print(aa(5)) 阅读全文
posted @ 2018-10-29 15:23 findtruth123 阅读(642) 评论(1) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 9 下一页