/*
struct TreeNode {
    int val;
    struct TreeNode *left;
    struct TreeNode *right;
    TreeNode(int x) :
            val(x), left(NULL), right(NULL) {
    }
};
*/
class Solution {
public:
    TreeNode * ret;
    int count = 0;
    void Inorder(TreeNode* pRoot, int k) {
        if (!pRoot) {
            return ;
        }
        Inorder(pRoot->left, k);
        count++;
        if (count == k) {
            ret = pRoot;
            return;
        } 
        if (count < k) {
            Inorder(pRoot->right, k);
        } else {
            return ;
        }
    }
    
    TreeNode* KthNode(TreeNode* pRoot, int k) {
        if (!pRoot || k == 0) {
            return ret;
        }
        Inorder(pRoot, k);
        return ret;
    }

    
};