The problem. Given the root of a binary search tree and two integers low and high, return the sum of every value in the range [low, high], inclusive.
root = [10, 5, 15, 3, 7, null, 18], low = 7, high = 15 -> 32
root = [10, 5, 15, 3, 7, 13, 18, 1, null, 6], low = 6, high = 10 -> 23 (6 + 7 + 10)Members only · free account
The rest of this lesson, with 7 more sections, 1 drawing, a dry-run simulator and code in JavaScript, Python, Java and C++, opens with a free account.
Not ready yet? The Arrays course is free to read, no account needed.
In the rest of this lesson