Beginner Friendly 100% beats 0ms 📈✅ 
IntuitionCan be found using inorder traversal because you known it visits nodes in sorted order. We keep a count while traversing and stop when we reach the k-t
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Can be found using inorder traversal because you known it visits nodes in sorted order. We keep a count while traversing and stop when we reach the k-th node that we want. then return the answer .

# Approach
<!-- Describe your approach to solving the problem. -->
1️⃣ Use Inorder Traversal because BST gives sorted order.
2️⃣ Keep a count of visited nodes while traversing (count).
3️⃣ When count == k, We can store the node's value and stop traversal.
4️⃣ Return the stored value as the k-th smallest element.


Please Upvote If It Helps ⬆️

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
O(1)

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
O(n)

# Code
```javascript []
/**
 * Definition for a binary tree node.
 * function TreeNode(val, left, right) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.left = (left===undefined ? null : left)
 *     this.right = (right===undefined ? null : right)
 * }
 */
/**
 * @param {TreeNode} root
 * @param {number} k
 * @return {number}
 */
var kthSmallest = function (root, k) {
    let ans
    let count = 0
    function inOrder(root) {
        if (!root) return   ///if root is null nothing to do
        inOrder(root.left)
        count++
        if (count === k) {      //when count===k store the value to ans
            return ans = root.val
        }
        inOrder(root.right)
    }
    inOrder(root)
    return ans
};
```
['Binary Search Tree', 'JavaScript']