Two Sum in BST

Construction and Iterator Patterns DSA practice problem on Onlearn.

Difficulty: medium.

Topics: How to check if there exists a pair with sum K in a Binary Search Tree (BST)?, Binary Search Tree, Tree Traversal, Hash Map, Two Pointers, Time Complexity, Space Complexity, Recursion, Arrays, inorder traversal, two pointer technique, hashing, binary search tree.

Given the root of a Binary Search Tree (BST) and an integer k, determine if there exist two distinct nodes in the tree whose values sum up to k. Return true if such a pair exists, and false otherwise. Input Specification: The input will consist of the root node of a Binary Search Tree and an integer k. Output Specification: Return a boolean value: true if a pair summing to k is found, false otherwise.