摘要:
class Solution: def getmaxValue(self, values, rows, cols): if not values or rows 0: up = temp[j] if j > 0: left = temp[j-1] ... 阅读全文
摘要:
def aa(n,q): m=str(n) for k,s in enumerate(m): if k==q: return s print(aa(232333,2)) 阅读全文
摘要:
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... 阅读全文
摘要:
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 ... 阅读全文
摘要:
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])) 阅读全文
摘要:
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... 阅读全文
摘要:
from itertools import permutations def my_permutation(s): str_set = [] ret = [] # 最后的结果 def permutation(string): for i in string: str_tem = string.replace(i, '') ... 阅读全文
摘要:
import random class Node(object): def __init__(self, val): self.val = val self.next = None self.other = None class Solution(object): @staticmethod def clone_... 阅读全文
摘要:
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] =... 阅读全文
摘要:
class minstack(object): def __init__(self): self.stack=[] self.min=[] def push(self,values): for i in values: self.stack.append(i) if ... 阅读全文
摘要:
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... 阅读全文