Hi, as for second method, DFS traverse.
I don't think the solution is optimal, for that code, if dfs return void, the time complexity is always o(n). we would have to run through all nodes.
My method intend to do early return, to avoid "run all nodes". Below is my code, please feel free to point any bugs, thanks
Kth Smallest Element in a BST