You are given the root of a Binary Search Tree (BST) and an integer k. Your task is to return the kth smallest element in the BST.
Input: root = [3,1,4,null,2], k = 1
Output: 1
Explanation: The smallest element in the BST is 1.
Input: root = [5,3,6,2,4,null,null,1], k = 3
Output: 3
Explanation: The elements in sorted order are 1, 2, 3, 4, 5, 6, so the 3rd smallest element is 3.
Input: root = [2,1,3], k = 2
Output: 2
Explanation: The 2nd smallest element in the BST is 2.
Sign in to write, run, and submit your solution against the full test suite.