摘要: class Solution: def getmaxValue(self, values, rows, cols): if not values or rows 0: up = temp[j] if j > 0: left = temp[j-1] ... 阅读全文
posted @ 2018-10-26 16:52 findtruth123 阅读(432) 评论(0) 推荐(0) 编辑
摘要: def aa(n,q): m=str(n) for k,s in enumerate(m): if k==q: return s print(aa(232333,2)) 阅读全文
posted @ 2018-10-26 16:20 findtruth123 阅读(711) 评论(0) 推荐(0) 编辑
摘要: def NumberOf1Between1AndN_Solution(self, n): mult, sumTimes = 1, 0 while n//mult > 0: high, mod = divmod(n, mult*10) curNum, low = divmod(mod, mult) if curNum > 1... 阅读全文
posted @ 2018-10-26 16:16 findtruth123 阅读(610) 评论(1) 推荐(0) 编辑
摘要: def aa(nums): if not nums: return False current=0 ret=float('-inf') for i in nums: if current n: current=m else: current=n ... 阅读全文
posted @ 2018-10-26 16:11 findtruth123 阅读(205) 评论(1) 推荐(0) 编辑
摘要: import heapq import math def aa(nums): mid=math.ceil(len(nums)/2) q=heapq.nlargest(mid,nums)[-1] m=heapq.nsmallest(mid,nums)[-1] return (m+q)/2 print(aa([1,2,3,3,4,5])) 阅读全文
posted @ 2018-10-26 15:43 findtruth123 阅读(595) 评论(0) 推荐(0) 编辑
摘要: def aa(nums): if not nums: return False hashes={} ret=[] for s in nums: hashes[s]=hashes[s]+1 if hashes.get(s) else 1 if hashes[s] >len(nums)/2: re... 阅读全文
posted @ 2018-10-26 13:37 findtruth123 阅读(230) 评论(0) 推荐(0) 编辑
摘要: from itertools import permutations def my_permutation(s): str_set = [] ret = [] # 最后的结果 def permutation(string): for i in string: str_tem = string.replace(i, '') ... 阅读全文
posted @ 2018-10-26 11:17 findtruth123 阅读(444) 评论(0) 推荐(0) 编辑
摘要: import random class Node(object): def __init__(self, val): self.val = val self.next = None self.other = None class Solution(object): @staticmethod def clone_... 阅读全文
posted @ 2018-10-26 11:10 findtruth123 阅读(350) 评论(0) 推荐(0) 编辑
摘要: def pop_order(push_stack, pop_stack): if not push_stack or not pop_stack: return False stack = [] while pop_stack: pop_val = pop_stack[0] if stack and stack[-1] =... 阅读全文
posted @ 2018-10-26 10:37 findtruth123 阅读(217) 评论(0) 推荐(0) 编辑
摘要: class minstack(object): def __init__(self): self.stack=[] self.min=[] def push(self,values): for i in values: self.stack.append(i) if ... 阅读全文
posted @ 2018-10-26 10:04 findtruth123 阅读(670) 评论(0) 推荐(0) 编辑
摘要: def aa(matrix): rows=len(matrix) cols=len(matrix[0]) start=0 ret=[] while start*2 <rows and start*2<cols: bb(matrix,rows,cols,start,ret) start +=1 ret... 阅读全文
posted @ 2018-10-26 09:56 findtruth123 阅读(816) 评论(0) 推荐(0) 编辑