← 返回 uber 的题目列表Find kth Largest Element in BST Using O(1) Space
类型:online_judge
uber
Given a binary search tree and an integer k, write an algorithm to find the kth largest element in the binary search tree. The algorithm should use O(1) space complexity, which means no extra data structures like stack or array can be used. The definition of tree nodes can be modified to include parent pointers or visited states.
Example
Input
root=[3,1,4,null,2], k=1