C++|| O(N) time and O(1) Space ||
\nclass Solution {\npublic: \n    void inord(TreeNode*root,int &k,int &ans){\n        if(root==NULL)\n            return;\n        inord(root->left,k,ans);\n   
```\nclass Solution {\npublic: \n    void inord(TreeNode*root,int &k,int &ans){\n        if(root==NULL)\n            return;\n        inord(root->left,k,ans);\n        k--;\n        if(k==0){\n            ans=root->val;\n            \n        }\n        inord(root->right,k,ans);\n    }\n    int kthSmallest(TreeNode* root, int k) {\n       int ans=-1;\n        inord(root,k,ans);\n        return ans;\n    }\n};\n```
['Recursion', 'C']