class Solution {
public:
int c = 0;
int ans = 0;
int kthSmallest(TreeNode* root, int k) {
if (root == NULL) return ans;
kthSmallest(root -> left, k);
c += 1;
if (c == k) ans = root -> val;
kthSmallest(root -> right, k);
return ans;
}
};
Time Complexity: O(n)
Space: O(1)