Two Sum IV - Input is a BST
@tlj77 thank you! This is a very good point!
@zestypanda This is a good interview question, I guess that would be O(N)?
In C++, I used recursive dfs.
In Python, I used a list for iterative bfs.
No one has replied
Since it's a BST, a better solution would take advantage of it by using two pointers pointing at the smallest and the largest.
@shreydesai Yep spot on, however because of the call stack this still does take O(logn) space
@shreydesai Thanks. that worked. but can you please elaborate on the reason for error.
Disabled Categories are greyed out
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.