leetcode_230. Kth Smallest Element in a BST
2018-04-12 04:18
495 查看
Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.
Note:
You may assume k is always valid, 1 ≤ k ≤ BST’s total elements.
Follow up:
What if the BST is modified (insert/delete operations) often and you need to find the kth smallest frequently? How would you optimize the kthSmallest routine?
提示:提交代码后,需要用简洁的语言解释一下代码思路~ 谢谢
历史题目和总结见公众号「每日一道算法题」
https://leetcode.com/problems/kth-smallest-element-in-a-bst/description/
思路:
Note:
You may assume k is always valid, 1 ≤ k ≤ BST’s total elements.
Follow up:
What if the BST is modified (insert/delete operations) often and you need to find the kth smallest frequently? How would you optimize the kthSmallest routine?
提示:提交代码后,需要用简洁的语言解释一下代码思路~ 谢谢
历史题目和总结见公众号「每日一道算法题」
https://leetcode.com/problems/kth-smallest-element-in-a-bst/description/
思路:
相关文章推荐
- leetcode 230. Kth Smallest Element in a BST
- leetcode_middle_26_230. Kth Smallest Element in a BST
- leetcode -- 230. Kth Smallest Element in a BST 【遍历 + 计数】
- LeetCode-230. Kth Smallest Element in a BST
- Leetcode 230. Kth Smallest Element in a BST
- Leetcode 230. Kth Smallest Element in a BST (Medium) (cpp)
- LeetCode 230. Kth Smallest Element in a BST
- [LeetCode] Algorithms-45. 230. Kth Smallest Element in a BST
- Leetcode 230. Kth Smallest Element in a BST
- [LeetCode]230. Kth Smallest Element in a BST
- Leetcode 230. Kth Smallest Element in a BST
- 【leetcode】230. Kth Smallest Element in a BST
- leetcode-java-230. Kth Smallest Element in a BST
- [LeetCode]230. Kth Smallest Element in a BST
- Leetcode 230. Kth Smallest Element in a BST
- [LeetCode] 230. Kth Smallest Element in a BST 二叉搜索树中的第K小的元素
- LeetCode 230. Kth Smallest Element in a BST
- LeetCode#230. Kth Smallest Element in a BST
- 【LeetCode】230. Kth Smallest Element in a BST (2 solutions)
- 【leetcode】230. Kth Smallest Element in a BST