From e0a83d20af335d67a6518e1fbdbaf968e6e4762b Mon Sep 17 00:00:00 2001 From: chayan das Date: Wed, 15 Oct 2025 23:57:33 +0530 Subject: [PATCH] Create 15 October k-th Smallest in BST --- 15 October k-th Smallest in BST | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 15 October k-th Smallest in BST diff --git a/15 October k-th Smallest in BST b/15 October k-th Smallest in BST new file mode 100644 index 0000000..e44f6ee --- /dev/null +++ b/15 October k-th Smallest in BST @@ -0,0 +1,12 @@ +class Solution { + public: + int kthSmallest(Node *root, int &k) { + // code here + if(root == NULL) return -1; + int tmp = kthSmallest(root -> left, k); + if(tmp != -1) return tmp; + k--; + if(k == 0) return root -> data; + return kthSmallest(root -> right, k); + } +};