摘要: 没能做出来,参考别人的: 1 from heapq import heapify, heappush, heappop 2 3 class Solution: 4 def findItinerary(self, tickets: List[List[str]]) -> List[str]: 5 gr 阅读全文
posted @ 2020-04-08 20:18 Sempron2800+ 阅读(188) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution: 2 def isValidSerialization(self, preorder: str) -> bool: 3 if preorder == '#':#空树是合法的 4 return True 5 nodes = preorder.split(',') 6 阅读全文
posted @ 2020-04-08 17:54 Sempron2800+ 阅读(175) 评论(0) 推荐(0) 编辑
摘要: 1 import sys 2 class Solution: 3 def nthSuperUglyNumber(self, n: int, primes: 'List[int]') -> int: 4 dp = [1]*n 5 m = len(primes) 6 plist = [0] * m 7 阅读全文
posted @ 2020-04-08 16:15 Sempron2800+ 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 尝试使用bfs解决,但是TLE。给出代码如下: 1 import sys 2 class Solution: 3 def __init__(self): 4 self.depth = [] 5 self.mindepth = sys.maxsize 6 7 def bfs(self,n,visite 阅读全文
posted @ 2020-04-08 11:53 Sempron2800+ 阅读(151) 评论(0) 推荐(0) 编辑