We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b5b10ee commit 7662c68Copy full SHA for 7662c68
kth-smallest-element-in-a-bst/flynn.cpp
@@ -1,10 +1,14 @@
1
/**
2
* For the height H of the given BST,
3
*
4
- * Time complexity: O(H) at worst
+ * Time complexity: O(max(H, K))
5
+ * - if H > K, O(H) at worst
6
+ * - else, O(K)
7
- * Space complexity: O(H + K) at worst
- * - call stack + additional vector to save nums
8
+ * Space complexity: O(H > K ? H + K : K)
9
+ * - additional vector to save nums O(K)
10
+ * - if H > K, call stack O(H)
11
12
*/
13
14
0 commit comments