摘要: from typing import Listclass Solution: # 第一种是我想的办法 def singleNumber(self, nums: List[int]) -> int: # 首先进行排序 nums.sort() # 然后判断重复的数字,数组中的数字必定为奇数个, # 如果 阅读全文
posted @ 2020-07-15 20:47 月为暮 阅读(330) 评论(1) 推荐(0) 编辑
摘要: # 二叉搜索树的特点是左子树小于根节点,右子树大于根节点。# 因此当根节点为i的时候,左子树的值为1:i-1,右子树为i+1:n# 当节点为n的时候所有的能够组成的树为左子树个数乘以右子树个数。class Solution: def numTrees(self, n: int) -> int: dp 阅读全文
posted @ 2020-07-15 19:54 月为暮 阅读(191) 评论(0) 推荐(0) 编辑