FastPrepRange Sum of BST
Problems/Range Sum of BST

Range Sum of BST

Meta logoMeta● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The Meta phone-screen report links the standard Range Sum of BST exercise. This practice follows the linked inclusive-range task and its published bounds. The report does not describe an interviewer variation. Source match is about 100%.

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

A node outside the range may still have descendants inside the range. Use the binary search tree ordering to skip subtrees only when it is safe.

Function

rangeSumBST(root: TreeNode, low: int, high: int) → int

Examples

Example 1

root = [10,5,15,3,7,null,18]low = 7high = 15return = 32
root
105371518

The values in the inclusive range are 7, 10, and 15. Their sum is 32.

Example 2

root = [10,5,15,3,7,13,18,1,null,6]low = 6high = 10return = 23
root
1053176151318

The values in the range are 6, 7, and 10. Their sum is 23.

Example 3

root = [8]low = 9high = 12return = 0
root
8

The tree has a single node, and its value is below the range. Nothing is added, so the sum is zero.

Constraints

  • The tree contains between 1 and 20000 nodes.
  • Node values are unique integers between 1 and 100000.
  • 1 <= low <= high <= 100000.
  • The tree is a valid binary search tree.

More Meta Phone Screen questions

  • Convert a Sorted Linked List to a Balanced BSTPHONE SCREEN · Seen Nov 2026
  • Fuzzy Word Lookup With One Misspelled LetterPHONE SCREEN · Seen Nov 2026
  • Multi-Head Attention Forward PassPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Run-Length Encoded Vector Dot ProductPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Mutual-Friend RecommendationsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best Time to Buy and Sell StockPHONE SCREEN · Seen Nov 2026
  • First Element Greater Than KPHONE SCREEN · Seen Nov 2026
  • Count Events in Rolling Minute WindowsPHONE SCREEN · Seen Oct 2026
  • Valid Word AbbreviationPHONE SCREEN · Seen Oct 2026
  • Shortest Path in a Binary MatrixPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Merge Two Binary TreesSnowflake · PHONE SCREENSnowflake interview questions
  • Sum All Values in a Binary TreeDuolingo · PHONE SCREENDuolingo interview questions
  • Sum Root-to-Leaf Binary NumbersOracle · PHONE SCREENOracle interview questions
  • Symmetric Binary TreeDocuSign · PHONE SCREENDocuSign interview questions
  • Count One-Valued Regions in a Binary TreeGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Maximum Depth of Binary TreeLinkedIn · PHONE SCREEN · ONSITE INTERVIEWLinkedIn interview questions
  • Maximum Value in a Binary TreeAkuna Capital · PHONE SCREENAkuna Capital interview questions
  • Root-to-Leaf Paths as StringsAdobe · PHONE SCREENAdobe interview questions
  • Org Chart Report CountsPatreon · PHONE SCREENPatreon interview questions
  • Left View of a Binary TreeMygate · PHONE SCREENMygate interview questions

Meta interview experiences

  • Meta PhD SWE Intern AI Coding Phone Screen: 1 Experience
  • Meta Business Support Engineer Phone Screen: 1 Experience
  • Meta Software Engineer Onsite Questions: 3 Experiences
  • Meta AI Native Engineer OA and Onsite: 1 Experience
  • Meta AI-Native Coding Interview: 3 Experiences
  • Meta Production Engineer Intern Questions: 6 Experiences
All Meta interview questionsSee Meta hiring insights
Saved
/**
 * Definition for a binary tree node.
 * public class TreeNode {
 *     int val;
 *     TreeNode left;
 *     TreeNode right;
 *     TreeNode() {}
 *     TreeNode(int val) { this.val = val; }
 *     TreeNode(int val, TreeNode left, TreeNode right) {
 *         this.val = val;
 *         this.left = left;
 *         this.right = right;
 *     }
 * }
 */
class Solution {
    public int rangeSumBST(TreeNode root, int low, int high) {
        // Write your code here
    }
}
Checking account…