(root, k, inOrder)
| 12 | }; |
| 13 | |
| 14 | const dfs = (root, k, inOrder) => { |
| 15 | if (root.left) kthSmallest(root.left, k, inOrder); |
| 16 | |
| 17 | inOrder.push(root.val); |
| 18 | |
| 19 | if (root.right) kthSmallest(root.right, k, inOrder); |
| 20 | |
| 21 | return inOrder[k - 1]; |
| 22 | }; |
| 23 | |
| 24 | /** |
| 25 | * https://leetcode.com/problems/kth-smallest-element-in-a-bst/ |
no test coverage detected