原创 119. 楊輝三角 II
class Solution: def getRow(self, rowIndex): """ :type rowIndex: int :rtype: List[int]
原创 127. 單詞接龍
class Solution: def ladderLength(self, beginWord, endWord, wordList): """ :type beginWord: str
原创 113. 路徑總和 II
class Solution: def pathSum(self, root, sum): """ :type root: TreeNode :type sum: int
原创 129. 求根到葉子節點數字之和
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x #
原创 114. 二叉樹展開爲鏈表
class Solution: def flatten(self, root): """ :type root: TreeNode :rtype: void Do not re
原创 121. 買賣股票的最佳時機
class Solution: def maxProfit(self, prices): """ :type prices: List[int] :rtype: int
原创 120. 三角形最小路徑和
class Solution: def minimumTotal(self, triangle): """ :type triangle: List[List[int]] :r
原创 106. 從中序與後序遍歷序列構造二叉樹
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x #
原创 110. 平衡二叉樹
def depth(node): if node is None: return 0 left = depth(node.left)
原创 109. 有序鏈表轉換二叉搜索樹
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x #
原创 108. 將有序數組轉換爲二叉搜索樹
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x #
原创 107. 二叉樹的層次遍歷 II
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x #
原创 103. 二叉樹的鋸齒形層次遍歷
class Solution: def zigzagLevelOrder(self, root): """ :type root: TreeNode :rtype: List[
原创 105. 從前序與中序遍歷序列構造二叉樹
class Solution: def buildTree(self, preorder, inorder): """ :type preorder: List[int] :t
原创 96. 不同的二叉搜索樹
class Solution: def numTrees(self, n): """ :type n: int :rtype: int """