0 day streak
Anonymous · shared experience20 Apr 2026 · 6 views

Josh Technology Group: Pair sum in a BST without a stack or list

Interview question #Josh Technology Group SDE 1 DSA / coding

Problem. Given a binary search tree and a target, find all pairs of nodes whose values add up to the target.

Constraints given. You may not use a stack or a temporary list to hold the inorder sequence.

Approach discussed. Walk from both ends at once with two in-order iterators, one forward and one reverse, built without a stack, for example with Morris traversal, and move them like two pointers.

Context. Part of a 2.5 hour final technical round that also had one-pass BST pruning without globals and unique combinations of M numbers summing to N.

0 comments

Comments 0

No comments yet. Ask the author something, or add what happened in your own round.