标签:roo null turn nod tree new class kth code
身体不好
1 class Solution { 2 public int kthSmallest(TreeNode root, int k) { 3 Stack<TreeNode> stack = new Stack<TreeNode>(); 4 while(root != null || !stack.empty()) { 5 while(root != null){ 6 stack.push(root); 7 root = root.left; 8 } 9 root = stack.pop(); 10 if(--k == 0) return root.val; 11 root = root.right; 12 } 13 return 0; 14 } 15 }
230. Kth Smallest Element in a BST
标签:roo null turn nod tree new class kth code
原文地址:https://www.cnblogs.com/goPanama/p/9573187.html