01 2020 档案
leetcode1334
摘要:1 from heapq import heappush, heappop 2 class Solution: 3 def findTheCity(self, n: int, edges: 'List[List[int]]', distanceThreshold: int) -> int: 4 di 阅读全文
posted @ 2020-01-26 18:02 Sempron2800+ 阅读(175) 评论(0) 推荐(0) 编辑
leetcode1333
摘要:1 class Solution: 2 def filterRestaurants(self, restaurants: 'List[List[int]]', veganFriendly: int, maxPrice: int, maxDistance: int) -> 'List[int]': 3 阅读全文
posted @ 2020-01-26 14:41 Sempron2800+ 阅读(136) 评论(0) 推荐(0) 编辑
leetcode1332
摘要:1 class Solution: 2 def isPalindrome(self,s): 3 n = len(s) 4 i,j = 0,n-1 5 while i < j: 6 if s[i] != s[j]: 7 return False 8 i += 1 9 j -= 1 10 return 阅读全文
posted @ 2020-01-26 14:06 Sempron2800+ 阅读(185) 评论(0) 推荐(0) 编辑
leetcode1331
摘要:1 class Solution: 2 def arrayRankTransform(self, arr: List[int]) -> List[int]: 3 n = len(arr) 4 if n == 0: 5 return [] 6 sortlist = sorted(arr) 7 dic 阅读全文
posted @ 2020-01-26 05:51 Sempron2800+ 阅读(100) 评论(0) 推荐(0) 编辑
leetcode1329
摘要:1 class Solution: 2 def diagonalSort(self, mat: 'List[List[int]]') -> 'List[List[int]]': 3 m = len(mat) 4 n = len(mat[0]) 5 6 i,j = m-1,0 7 while i != 阅读全文
posted @ 2020-01-26 05:49 Sempron2800+ 阅读(207) 评论(0) 推荐(0) 编辑
leetcode1328
摘要:1 class Solution: 2 def breakPalindrome(self, palindrome: str) -> str: 3 n = len(palindrome) 4 if n <= 1: 5 return '' 6 half = n // 2 7 sub = palindro 阅读全文
posted @ 2020-01-26 05:12 Sempron2800+ 阅读(157) 评论(0) 推荐(0) 编辑
leetcode1325
摘要:1 class Solution: 2 def __init__(self): 3 self.tag = True 4 5 def preOrder(self,root,target): 6 if root != None: 7 if root.left != None: 8 if root.lef 阅读全文
posted @ 2020-01-19 21:16 Sempron2800+ 阅读(124) 评论(0) 推荐(0) 编辑
leetcode1324
摘要:1 class Solution: 2 def printVertically(self, s: str) -> 'List[str]': 3 words = s.split(' ') 4 matrix = [] 5 maxlen = 0 6 for w in words: 7 maxlen = m 阅读全文
posted @ 2020-01-19 20:53 Sempron2800+ 阅读(176) 评论(0) 推荐(0) 编辑
leetcode1323
摘要:1 class Solution: 2 def maximum69Number (self, num: int) -> int: 3 result = '' 4 str_num = str(num) 5 i = 0 6 while i < len(str_num): 7 if str_num[i] 阅读全文
posted @ 2020-01-19 20:34 Sempron2800+ 阅读(145) 评论(0) 推荐(0) 编辑
leetcode1268
摘要: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+ 阅读(161) 评论(0) 推荐(0) 编辑
leetcode1311
摘要: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+ 阅读(209) 评论(0) 推荐(0) 编辑
leetcode1319
摘要: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) 编辑
leetcode1318
摘要: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) 编辑
leetcode1317
摘要: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+ 阅读(158) 评论(0) 推荐(0) 编辑
leetcode1315
摘要: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+ 阅读(212) 评论(0) 推荐(0) 编辑
leetcode1314
摘要: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+ 阅读(190) 评论(0) 推荐(0) 编辑
leetcode1313
摘要: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) 编辑
leetcode1310
摘要: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) 编辑
leetcode1309
摘要:倒序遍历,遇到#则读取前2位,并转换位字母,否则读取当前位转换位字母。 阅读全文
posted @ 2020-01-05 10:48 Sempron2800+ 阅读(133) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示