摘要: 首先用flooding,暴力的多次bfs,差一点就要超时 from queue import Queue class Solution: def markDistance(self, grid, i, j): m = len(grid) n = len(grid[0]) distance = [[N 阅读全文
posted @ 2020-02-01 21:20 阿牧遥 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 用了python的set。为了效率,先做了预处理,并排序了。要注意,排序完才好预处理,否则i,j会对不上。 class Solution: def maxProduct(self, words: List[str]) -> int: maxProd = 0 words = sorted(words, 阅读全文
posted @ 2020-02-01 19:50 阿牧遥 阅读(90) 评论(0) 推荐(0) 编辑
摘要: 使用了queue from queue import Queue class MovingAverage: def __init__(self, size: int): """ Initialize your data structure here. """ self.que = Queue() s 阅读全文
posted @ 2020-02-01 18:04 阿牧遥 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 简单的利用递归来做 # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class 阅读全文
posted @ 2020-02-01 17:28 阿牧遥 阅读(121) 评论(0) 推荐(0) 编辑