Simple and clean code using Inorder Traversal
Intuition\n Describe your first thoughts on how to solve this problem. \nFirst convert tree into a sorted array and return the kth element.\n\n\n# Approach\n De
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nFirst convert tree into a sorted array and return the kth element.\n\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nBy using inorder traversal convert Tree into an array and since it is a BST ,the array is already sorted.\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    vector<int>v;\n    void inorder(TreeNode* root){\n        if(root==NULL)return;\n        inorder(root->left);\n        v.push_back(root->val);\n        inorder(root->right);\n    }\n    int kthSmallest(TreeNode* root, int k) {\n        inorder(root);\n        return v[k-1];\n    }\n};\n```
['C++']