Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.

Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).

Click here to see the full article post

Approach #2 : Space complexity should be O(n). The size of the set+queue can grow upto n in the worst case.

You didn't use the info Binary Search Tree at all.

@zestypanda I've updated the article. Thanks for the valuable feedback.

@aayushgarg You're right. Thanks for pointing out.

@vinod23 whats your take on converting the BST to doubly linked list and then find the two sum.

@kool This cannot be done in O(n) time and O(logN) space. What if height of my BST is N?

Can be good, if the desired optimization (time vs space) was put on challenge description, because a in-place search on this tree can be made at time O(N * log(N)) and space O(1).

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.