230. Kth Smallest Element in a BST
来源:互联网 发布:网络摄像机组装配件 编辑:程序博客网 时间:2024/05/14 23:45
class Solution {public: int ans;int step;stack<TreeNode*> s;Solution(){step = 0;} int kthSmallest(TreeNode* root, int k) {TreeNode *p = root;while(p || !s.empty()){while(p){s.push(p);p = p->left;}if(!s.empty()){p = s.top();s.pop();++step;if(step == k)return p->val;p = p->right;}}return 0; }};
阅读全文
0 0
- 230.Kth Smallest Element in a BST
- 230. Kth Smallest Element in a BST
- 230. Kth Smallest Element in a BST
- 230. Kth Smallest Element in a BST
- 230. Kth Smallest Element in a BST
- 230. Kth Smallest Element in a BST
- 230. Kth Smallest Element in a BST
- 230. Kth Smallest Element in a BST
- 230. Kth Smallest Element in a BST
- 230. Kth Smallest Element in a BST
- 230. Kth Smallest Element in a BST
- 230. Kth Smallest Element in a BST
- 230. Kth Smallest Element in a BST
- 230. Kth Smallest Element in a BST
- 230. Kth Smallest Element in a BST
- 230. Kth Smallest Element in a BST
- 230. Kth Smallest Element in a BST
- 230. Kth Smallest Element in a BST
- 【牛客】星际穿越
- kubernetes init-container
- UVALive
- POJ
- LeetCode 205. Isomorphic Strings
- 230. Kth Smallest Element in a BST
- Combination Sum
- bzoj 3107: [cqoi2013]二进制a+b 数位dp
- C++实现复数Complex
- 认识HTML5的WebSocket
- Leetcode之Spiral Matrix II 问题
- 【LeetCode算法练习(C++)】Regular Expression Matching
- 习题6-5 巡逻机器人(Patrol Robot, ACM/ICPC Hanoi 2006, UVa1600)
- HDU-1061-Rightmost Digit【快速幂】