private static void Helper(LeetCode230TreeNode root) { if (root == null) { return; } Helper(root.left); list.Add(root.val); Helper(root.right); }
public static int KthSmallestElement(LeetCode230TreeNode root, int k) { Helper(root); return(list[k - 1]); }
public LeetCode230TreeNode(int val = 0, LeetCode230TreeNode left = null, LeetCode230TreeNode right = null) { this.val = val; this.left = left; this.right = right; }