2 BEST C++ solutions || Recursive, iterative and Morris inorder traversal || Beats 100% !!
Code\n\n// Inorder iterative solution\nclass Solution {\npublic:\n    int kthSmallest(TreeNode* root, int k) {\n        stack<TreeNode*> s;\n\n        while(!s.
# Code\n```\n// Inorder iterative solution\nclass Solution {\npublic:\n    int kthSmallest(TreeNode* root, int k) {\n        stack<TreeNode*> s;\n\n        while(!s.empty() || root != NULL){\n            while(root != NULL){\n                s.push(root);\n                root = root->left;\n            }\n            root = s.top();\n            s.pop();\n            if(--k == 0)\n                break;\n            root = root->right;\n        }\n        return root->val;\n    }\n};\n\n// Inorder Recursive solution\nclass Solution{\npublic:\n    void inorder(TreeNode *root, int &k, int &ans){\n        if(root == NULL)\n            return;\n        \n        inorder(root->left, k, ans);\n        if(--k == 0)\n            ans = root->val;\n        inorder(root->right, k, ans);\n    }\n    \n    int kthSmallest(TreeNode *root, int k){\n        int ans = 0;\n        inorder(root, k, ans);\n        return ans;\n    }\n};\n```
['Tree', 'Depth-First Search', 'Binary Search Tree', 'Binary Tree', 'C++']