摘要: 题目描述: 第一次提交;超时 class Solution: def jump(self, nums: List[int]) -> int: l = [] for i in range(len(nums)): l.append(i) for i, v in enumerate(nums): for 阅读全文
posted @ 2019-04-19 19:54 oldby 阅读(412) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 第一次提交: class Solution: def canJump(self, nums: List[int]) -> bool: if len(nums)<=1: return True for i,v in enumerate(nums): if i == 0 and v == 0 阅读全文
posted @ 2019-04-19 17:19 oldby 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 似然概率https://blog.csdn.net/u014182497/article/details/82252456 极大似然https://blog.csdn.net/qq_32742009/article/details/81460815 最大后验概率估计https://blog.csdn 阅读全文
posted @ 2019-04-11 12:14 oldby 阅读(93) 评论(0) 推荐(0) 编辑
摘要: 题目描述; 第一次提交; class Solution: def isUnivalTree(self, root: TreeNode) -> bool: if root == None: return True if root.left!=None and root.left.val!=root.v 阅读全文
posted @ 2019-03-31 18:28 oldby 阅读(120) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一: class Solution: def findMode(self, root: TreeNode) -> List[int]: if not root: return [] dic = {} stack = [root] while stack: node = stack.p 阅读全文
posted @ 2019-03-30 20:53 oldby 阅读(251) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一:栈 class Solution(object): def pathSum(self, root, sum): """ :type root: TreeNode :type sum: int :rtype: int """ count = 0 if root == None: r 阅读全文
posted @ 2019-03-29 20:12 oldby 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 方法一:递归 class Solution: def sumOfLeftLeaves(self, root: TreeNode) -> int: if not root: return 0 if root.left and root.left.left == None and root. 阅读全文
posted @ 2019-03-29 19:20 oldby 阅读(105) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 利用二叉搜索树的特点,如果p、q的值都小于root,说明p q 肯定在root的左子树中;如果p q都大于root,说明肯定在root的右子树中,如果一个在左一个在右 则说明此时的root记为对应的最近公共祖先 方法一:递归 class Solution: def lowestCommo 阅读全文
posted @ 2019-03-29 18:15 oldby 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 第一次提交:参考113-路径总和② class Solution: def binaryTreePaths(self, root: TreeNode) -> List[str]: r = [] if not root: return r l = "" def path(root, l): 阅读全文
posted @ 2019-03-28 18:05 oldby 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 第一次提交: class Solution(object): def invertTree(self, root): """ :type root: TreeNode :rtype: TreeNode """ if not root: return None temp = root.le 阅读全文
posted @ 2019-03-27 22:11 oldby 阅读(110) 评论(0) 推荐(0) 编辑