上一页 1 ··· 31 32 33 34 35 36 37 38 39 ··· 114 下一页
摘要: 1 class TrieNode: 2 def __init__(self): 3 self.children = dict() 4 self.words = [] 5 6 class Trie: 7 def __init__(self): 8 self.root = TrieNode() 9 10 阅读全文
posted @ 2020-01-14 16:38 Sempron2800+ 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution: 2 def getLevelFriends(self,friends,visited,id,level,l): 3 while len(l) > 0 and level > 0: 4 temp = [] 5 while len(l) > 0: 6 cur = l. 阅读全文
posted @ 2020-01-14 10:37 Sempron2800+ 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution: 2 def bfs(self,connections,visited,l,neighbours): 3 while len(l) > 0: 4 temp = [] 5 while len(l) > 0: 6 p = l.pop() 7 if visited[p] 阅读全文
posted @ 2020-01-13 14:22 Sempron2800+ 阅读(199) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution: 2 def converToBin(self,n): 3 N = [0] * 32 4 i = 31 5 while n != 0: 6 r = n % 2 7 N[i] = r 8 i -= 1 9 n = n // 2 10 return N 11 def m 阅读全文
posted @ 2020-01-12 10:53 Sempron2800+ 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution: 2 def isNonZeroNum(self,m): 3 s = str(m) 4 for i in range(len(s)): 5 if s[i] == '0': 6 return False 7 return True 8 9 def getNoZeroI 阅读全文
posted @ 2020-01-12 10:50 Sempron2800+ 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution: 2 def __init__(self): 3 self.result = 0 4 5 def preOrder(self,root): 6 if root != None: 7 if root.val % 2 == 0: 8 self.levelOrder(ro 阅读全文
posted @ 2020-01-11 23:59 Sempron2800+ 阅读(211) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution: 2 def matrixBlockSum(self, mat: 'List[List[int]]', K: int) -> 'List[List[int]]': 3 r,c = len(mat),len(mat[0]) 4 prefixsum = [[0 for 阅读全文
posted @ 2020-01-11 23:57 Sempron2800+ 阅读(188) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution: 2 def decompressRLElist(self, nums: 'List[int]') -> 'List[int]': 3 n = len(nums) 4 i = 0 5 res = [] 6 while i < n: 7 a = nums[i] 8 b 阅读全文
posted @ 2020-01-11 23:55 Sempron2800+ 阅读(208) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution: 2 def xorQueries(self, arr: 'List[int]', queries: 'List[List[int]]') -> 'List[int]': 3 n = len(arr) 4 prefixsum = [arr[0]] * n 5 res 阅读全文
posted @ 2020-01-11 19:13 Sempron2800+ 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 倒序遍历,遇到#则读取前2位,并转换位字母,否则读取当前位转换位字母。 阅读全文
posted @ 2020-01-05 10:48 Sempron2800+ 阅读(133) 评论(0) 推荐(0) 编辑
上一页 1 ··· 31 32 33 34 35 36 37 38 39 ··· 114 下一页