摘要:
题目描述: 第一次提交:BFS O(N) O(N) # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # 阅读全文
摘要:
题目描述: 方法一:递归 # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = 阅读全文
摘要:
题目描述: 方法一: class Solution(object): def rob(self, nums): """ :type nums: List[int] :rtype: int """ def dp(nums): pre = 0 cur = 0 for i in nums: temp = 阅读全文
摘要:
题目描述: 方法一:O(N) O(N) class Solution(object): def rob(self, nums): """ :type nums: List[int] :rtype: int """ bp = [0] * (len(nums) + 2) for i in range(l 阅读全文
摘要:
题目描述; 第一次提交: class Solution(object): def hammingWeight(self, n): """ :type n: int :rtype: int """ n = str(bin(n)) count = 0 for i in n: if i == '1': c 阅读全文
摘要:
题目描述: 方法一:内置函数 class Solution: # @param n, an integer # @return an integer def reverseBits(self, n): return int(bin(n)[2:].zfill(32)[::-1],2) 方法二:位运算 阅读全文
摘要:
题目描述: 方法一: class Solution: def rotate(self, nums: List[int], k: int) -> None: """ Do not return anything, modify nums in-place instead. """ for i in r 阅读全文
摘要:
题目描述: 方法一: class Solution: def findRepeatedDnaSequences(self, s: str) -> List[str]: n = 10 d = {} for i in range(len(s)-9): if s[i:i+10] in d: d[s[i:i 阅读全文
摘要:
题目描述: 方法一: class LargerNumKey(str): def __lt__(x, y): return x+y > y+x class Solution: def largestNumber(self, nums): largest_num = ''.join(sorted(map 阅读全文
摘要:
题目描述: 方法一: # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class 阅读全文