PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Meta

Solve BST range average and merge intervals

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of binary search tree properties and range-based traversal pruning for computing aggregates, together with techniques for merging two sorted interval lists into non-overlapping ranges, testing proficiency with tree and interval data structures and aggregate computation in the Coding & Algorithms domain.

  • Medium
  • Meta
  • Coding & Algorithms
  • Software Engineer

Solve BST range average and merge intervals

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

1) Given a binary search tree and an inclusive range [L, R], compute both the sum and the average of all node values where L <= val <= R. Use the BST property to prune traversal. Implement sumAndAverageInRange(root, L, R) -> (sum: int, average: float). Specify how to handle the case when no nodes fall in the range, and analyze time/space complexity. 2) Given two lists of intervals A and B, each list sorted by start time in ascending order (intervals are [start, end] with start <= end), merge them into a single list of non-overlapping intervals covering all intervals from A ∪ B. Clarify whether touching intervals (e.g., [1,3] and [3,5]) should be merged, handle potentially overlapping intervals within and across lists, implement mergeTwoSortedIntervalLists(A, B), and analyze complexity.

Quick Answer: This question evaluates understanding of binary search tree properties and range-based traversal pruning for computing aggregates, together with techniques for merging two sorted interval lists into non-overlapping ranges, testing proficiency with tree and interval data structures and aggregate computation in the Coding & Algorithms domain.

Related Interview Questions

  • Solve Tree Columns And Maze Variants - Meta (medium)
  • Solve a Key-Door Corridor Maze - Meta (medium)
  • Solve Array Merge and Parentheses Cleanup - Meta (medium)
  • Solve Two Backtracking Array Problems - Meta (hard)
  • Solve Maze and Suffix Problems - Meta (medium)
Meta logo
Meta
Sep 6, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
3
0
  1. Given a binary search tree and an inclusive range [L, R], compute both the sum and the average of all node values where L <= val <= R. Use the BST property to prune traversal. Implement sumAndAverageInRange(root, L, R) -> (sum: int, average: float). Specify how to handle the case when no nodes fall in the range, and analyze time/space complexity.
  2. Given two lists of intervals A and B, each list sorted by start time in ascending order (intervals are [start, end] with start <= end), merge them into a single list of non-overlapping intervals covering all intervals from A ∪ B. Clarify whether touching intervals (e.g., [1,3] and [3,5]) should be merged, handle potentially overlapping intervals within and across lists, implement mergeTwoSortedIntervalLists(A, B), and analyze complexity.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Meta•More Software Engineer•Meta Software Engineer•Meta Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.