PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Meta

Compute interval mode, BST range sum, exclusive time

Last updated: Mar 29, 2026

Quick Overview

This multipart question evaluates proficiency in interval coverage and frequency analysis, binary search tree range-sum queries with preprocessing for repeated queries, and exclusive-time computation from call logs, covering concepts such as event counting/sweep-line, BST traversal and augmentation, and nested-call time accounting.

  • medium
  • Meta
  • Coding & Algorithms
  • Software Engineer

Compute interval mode, BST range sum, exclusive time

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

You are given several independent coding tasks. ### A) Most frequent integer covered by intervals You are given an integer range `[-M, M]` and a list of inclusive integer intervals, e.g. `[1, 3]` means the integers `{1,2,3}` are each covered once by that interval. Multiple intervals may overlap. Return **any** integer in `[-M, M]` that has the **maximum total coverage count** (i.e., appears in the most intervals when expanded to integers). If multiple integers tie for the maximum, returning any one of them is fine. Clarify assumptions/constraints you need (e.g., size of `M`, number of intervals, endpoints within `[-M, M]`). --- ### B) Range sum on a BST + follow-up optimization Given the root of a Binary Search Tree (BST) and two integers `low` and `high`, return the **sum of all node values** `v` such that `low <= v <= high`. **Follow-up:** Suppose the tree is very large and you need to answer **many** queries with different `[low, high]` ranges. What preprocessing or data structure would you use to make queries faster? --- ### C) Exclusive execution time from logs There are `n` functions labeled `0..n-1`. You are given a list of logs in chronological order. Each log is a string formatted as: `"<functionId>:start:<timestamp>"` or `"<functionId>:end:<timestamp>"` - `start` means the function starts at that timestamp. - `end` means the function ends at that timestamp (inclusive). - Functions may be nested due to calls. Return an array `ans` of length `n` where `ans[i]` is the **exclusive time** spent in function `i` (time in `i` excluding time in any functions it calls). State any needed assumptions (e.g., timestamps are integers, single-threaded execution).

Quick Answer: This multipart question evaluates proficiency in interval coverage and frequency analysis, binary search tree range-sum queries with preprocessing for repeated queries, and exclusive-time computation from call logs, covering concepts such as event counting/sweep-line, BST traversal and augmentation, and nested-call time accounting.

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
Oct 2, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
1
0

You are given several independent coding tasks.

A) Most frequent integer covered by intervals

You are given an integer range [-M, M] and a list of inclusive integer intervals, e.g. [1, 3] means the integers {1,2,3} are each covered once by that interval. Multiple intervals may overlap.

Return any integer in [-M, M] that has the maximum total coverage count (i.e., appears in the most intervals when expanded to integers). If multiple integers tie for the maximum, returning any one of them is fine.

Clarify assumptions/constraints you need (e.g., size of M, number of intervals, endpoints within [-M, M]).

B) Range sum on a BST + follow-up optimization

Given the root of a Binary Search Tree (BST) and two integers low and high, return the sum of all node values v such that low <= v <= high.

Follow-up: Suppose the tree is very large and you need to answer many queries with different [low, high] ranges. What preprocessing or data structure would you use to make queries faster?

C) Exclusive execution time from logs

There are n functions labeled 0..n-1. You are given a list of logs in chronological order. Each log is a string formatted as:

"<functionId>:start:<timestamp>" or "<functionId>:end:<timestamp>"

  • start means the function starts at that timestamp.
  • end means the function ends at that timestamp (inclusive).
  • Functions may be nested due to calls.

Return an array ans of length n where ans[i] is the exclusive time spent in function i (time in i excluding time in any functions it calls).

State any needed assumptions (e.g., timestamps are integers, single-threaded execution).

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.