Given a binary search tree, write a function `kthSmallest`

to find the **k**th smallest element in it.

**Note: **

You may assume k is always valid, 1 ≤ k ≤ BST’s total elements.

**Solution** : using pre-order travel of the tree, the kth element is the kth smallest element.

int result = 0; public int KthSmallest(TreeNode root, int k) { KthSmallestHelper(root, ref k); return result; } private void KthSmallestHelper(TreeNode root, ref int k) { if (root == null) return; KthSmallestHelper(root.left, ref k); if (--k == 0) { result = root.val; return; } KthSmallestHelper(root.right, ref k); }