题目
思路
代码
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def kthLargest(self, root: TreeNode, k: int) -> int:
nodes=[]
def recur(root):
if not root :return
recur(root.left)
nodes.append(root.val)
recur(root.right)
recur(root)
print(nodes)
return nodes[-k]