摘要:
方法: class Solution: def productExceptSelf(self, nums: [int]) -> [int]: res, p, q = [1], 1, 1 for i in range(len(nums) - 1): # top triangle p *= nums[i 阅读全文
摘要:
题目描述: 方法: class Solution: def deleteNode(self, node): """ :type node: ListNode :rtype: void Do not return anything, modify node in-place instead. """ 阅读全文
摘要:
题目描述: 方法一: # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class 阅读全文
摘要:
题目描述: 方法:动态规划 class Solution: def isValidPalindrome(self, s: str, k: int) -> bool: def isKPalRec(str1, str2, m, n): dp = [[0] * (n + 1) for _ in range 阅读全文
摘要:
题目描述: 自己的提交:参考全排列 class Solution: def countSteppingNumbers(self, low: int, high: int) -> List[int]: a = [i for i in range(10)] res =[] def helper(num) 阅读全文
摘要:
题目描述: 自己的提交: class Solution: def twoSumBSTs(self, root1: TreeNode, root2: TreeNode, target: int) -> bool: if not root1 :return root_copy = root2 while 阅读全文
摘要:
题目描述: 自己的提交: class Solution: def arraysIntersection(self, arr1: List[int], arr2: List[int], arr3: List[int]) -> List[int]: arr = arr1 + arr2 +arr3 res 阅读全文
摘要:
题目描述: 方法:倒推 class Solution(object): def countVowelPermutation(self, n): MOD = 10 ** 9 + 7 a=e=i=o=u= 1 for ZZZ in xrange(n-1): a2,e2,i2,o2,u2 = e+i+u, 阅读全文
摘要:
题目描述: 方法一:dfs class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: maxx = 0 R, C = len(grid), len(grid[0]) def dfs(r, c, visited, c 阅读全文
摘要:
题目描述: class Solution: def longestSubsequence(self, arr: List[int], difference: int) -> int: dp = dict() for a in arr: pre = a - difference if pre in d 阅读全文