We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 37b25e7 commit 76118e6Copy full SHA for 76118e6
tree_problems/kth_smallest.cpp
@@ -36,7 +36,7 @@ int kthSmallest(TreeNode* root, int k)
36
int count = countNodes(root->left);
37
if (k <= count && root->left) {
38
return kthSmallest(root->left, k);
39
- } else if ( k + 1 >= count && root->right) {
+ } else if ( k > count + 1 && root->right) {
40
return kthSmallest(root->right, k - count - 1);
41
}
42
return root->data;
0 commit comments