Tap here to switch tabs
Problem
Submissions

Problem: Range Sum of BST

Try to solve the Range Sum of BST problem.

Statement

Given the root node of a binary search tree and two integers low and high, return the sum of values of all nodes with a value in the inclusive range [[low, high]].

Constraints:

  • The number of nodes in the tree is in the range [1,2imes104][1, 2 imes 10^4].

  • 1≤1 \leq Node.val ≤105\leq 10^5

  • 1≤1 \leq low ≤\leq high ≤105\leq 10^5

  • All Node.val are unique.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Range Sum of BST

Try to solve the Range Sum of BST problem.

Statement

Given the root node of a binary search tree and two integers low and high, return the sum of values of all nodes with a value in the inclusive range [[low, high]].

Constraints:

  • The number of nodes in the tree is in the range [1,2imes104][1, 2 imes 10^4].

  • 1≤1 \leq Node.val ≤105\leq 10^5

  • 1≤1 \leq low ≤\leq high ≤105\leq 10^5

  • All Node.val are unique.