Can you find the kth ancestor in a splay tree? A link-cut tree is just a splay tree. → Reply » » freto 5 years ago, # ^ | 0 i do not understand. well yes it is just a splay tree, but how to get the kth ancestor query along with link/cut queries supported? → ...
LeetCode215-kth-largest-element-in-an-array 第k 大的元素 这题用递归出错了,划不来,一点都不好debug, 最重要的是抽线能力 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 ...
Kth Smallest Element in a BST 1 class Solution { 2 public: 3 int rank; 4 int result; 5 6 void help(TreeNode* root, int k){ 7 if(!root) return; 8 9 help(root->left, k); 10 if(++rank == k){ 11 result = root->val; 12 return; 13 } 14 help(root->right, k); 15 }...