0653. Two Sum IV - Input is a BST
Easy | Binary Search Tree + Stack | 72 ms (92.85%), 16.6 MB (76.64%)
Source: LeetCode - Two Sum IV - Input is a BST GitHub: Solution / Performance
Given the root
of a Binary Search Tree and a target number k
, return true
if there exist two elements in the BST such that their sum is equal to the given target.
Using "Stack" to traverse BST and using "Set" to record each node value.
Last updated
Was this helpful?