LeetCode 230. Kth Smallest Element in a BST
来源:互联网 发布:h5砸金蛋游戏源码 编辑:程序博客网 时间:2024/06/07 14:18
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */public class Solution { public int kthSmallest(TreeNode root, int k) { Stack<TreeNode> stack = new Stack<TreeNode>(); while (root != null) { stack.push(root); root = root.left; } while (k != 0) { TreeNode n = stack.pop(); if (--k == 0) return n.val; n = n.right; while (n != null) { stack.push(n); n = n.left; } } return Integer.MIN_VALUE; }}
0 0
- #leetcode#Kth Smallest Element in a BST
- leetcode--Kth Smallest Element in a BST
- Leetcode|Kth Smallest Element in a BST
- [leetcode] Kth Smallest Element in a BST
- 【LeetCode】Kth Smallest Element in a BST
- LeetCode Kth Smallest Element in a BST
- 【leetcode】Kth Smallest Element in a BST
- LeetCode Kth Smallest Element in a BST
- leetcode: Kth Smallest Element in a BST
- Leetcode: Kth Smallest Element in a BST
- [LeetCode] Kth Smallest Element in a BST
- [LeetCode]Kth Smallest Element in a BST
- [Leetcode]Kth Smallest Element in a BST
- leetcode--Kth Smallest Element in a BST
- 【leetcode】Kth Smallest Element in a BST
- [leetcode] Kth Smallest Element in a BST
- [Leetcode]Kth Smallest Element in a BST
- Leetcode: Kth Smallest Element in a BST
- CSS学习
- 290. Word Pattern*
- Box2D中切割刚体效果的实现一览(一)
- 【BZOJ 3524】[Poi2014]Couriers 主席树裸题
- Centos7使用编译源码方式安装mysql
- LeetCode 230. Kth Smallest Element in a BST
- MongoDB范式化与反范式化
- CNN公式推导
- Box2D中切割刚体效果的实现一览(二)
- Box2D中切割刚体效果的实现一览(完)
- css3(border-radius)边框圆角详解
- 图
- [C++] C++ DFS 记录层数两种写法dfs(int v) dfs(int v,int level)
- linux之vim怎么跳到指定的一行