Given the root of a BST and an integer k, return the kth smallest value (1-indexed) of all the values in the tree.
Example: In BST , the 1st smallest is 1, 2nd is 2, 3rd is 3. This problem directly tests whether you understand the inorder property of BSTs.
Follow-up: If the BST is modified often (insert/delete) and you need to find kth smallest frequently, how would you optimize? Constraints: is in range , up to nodes.