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