摘要:
原题链接:https://leetcode-cn.com/problems/climbing-stairs/ 解题思路:动态规划 状态转移方程:dp[i] = dp[i-1] + dp[i-2] 代码: 1 class Solution: 2 def climbStairs(self, n: int 阅读全文
posted @ 2022-01-11 22:59
CaptainDragonfly
阅读(47)
评论(0)
推荐(0)
摘要:
原题链接:https://leetcode-cn.com/problems/day-of-the-year/ 代码: 1 import datetime 2 class Solution: 3 def dayOfYear(self, date: str) -> int: 4 dd = datetim 阅读全文
posted @ 2022-01-11 22:50
CaptainDragonfly
阅读(22)
评论(0)
推荐(0)
摘要:
原题链接:https://leetcode-cn.com/problems/maximum-depth-of-binary-tree/ 解题思路:递归 代码: 1 # Definition for a binary tree node. 2 # class TreeNode: 3 # def __i 阅读全文
posted @ 2022-01-11 22:48
CaptainDragonfly
阅读(24)
评论(0)
推荐(0)
摘要:
原题链接:https://leetcode-cn.com/problems/binary-tree-postorder-traversal/ 解法一:递归,需了解树的递归式遍历 1 # Definition for a binary tree node. 2 # class TreeNode: 3 阅读全文
posted @ 2022-01-11 22:41
CaptainDragonfly
阅读(31)
评论(0)
推荐(0)
摘要:
原题链接:https://leetcode-cn.com/problems/binary-tree-inorder-traversal/ 方法一:递归,需了解树的递归序遍历 1 # Definition for a binary tree node. 2 # class TreeNode: 3 # 阅读全文
posted @ 2022-01-11 22:37
CaptainDragonfly
阅读(26)
评论(0)
推荐(0)
摘要:
原题链接:https://leetcode-cn.com/problems/binary-tree-preorder-traversal/ 方法一:递归,需了解树的递归序遍历 1 # Definition for a binary tree node. 2 # class TreeNode: 3 # 阅读全文
posted @ 2022-01-11 22:31
CaptainDragonfly
阅读(26)
评论(0)
推荐(0)
摘要:
原题链接:https://leetcode-cn.com/problems/validate-binary-search-tree/ 二叉搜索树的性质:二叉树中序遍历的结果为递增序列 解法一:采用递归法中序遍历,比较相邻节点的大小 # Definition for a binary tree nod 阅读全文
posted @ 2022-01-11 22:00
CaptainDragonfly
阅读(27)
评论(0)
推荐(0)

浙公网安备 33010602011771号