PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates skills in interval manipulation and boolean-based merging, along with binary-tree traversal and side-view extraction for string construction, assessing data-structure proficiency and algorithmic reasoning.

  • easy
  • Bloomberg
  • Coding & Algorithms
  • Software Engineer

Solve meeting and tree problems

Company: Bloomberg

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Technical Screen

The interview included two coding tasks: 1. **Merge meeting intervals** You are given a list of meeting intervals `[[start, end], ...]`, not necessarily sorted. Return the smallest list of merged intervals that covers the same occupied time. Merge intervals that overlap or touch. **Follow-up:** each interval becomes `[start, end, is_available]`, where `is_available` is a boolean. Return only the merged intervals during which the person is unavailable. Treat any time covered by at least one interval with `is_available = false` as unavailable. 2. **Build a string from binary-tree side views** Each node of a binary tree stores a character. - The **left side view** is the set of nodes visible when looking at the tree from the left, one node per depth. - The **right side view** is the set of nodes visible when looking at the tree from the right, one node per depth. Return a string formed by: - taking the left side view from **bottom to top**, then - appending the right side view from **bottom to top**, while avoiding duplicates for nodes already included from the left side view. Example tree: - root: `i` - left child: `r` - right child: `y` - `r` has children `p` and `v` The output should be `privy`. **Follow-up:** if the right side view is appended from **top to bottom** instead, the output for the same tree becomes `priyv`.

Quick Answer: This question evaluates skills in interval manipulation and boolean-based merging, along with binary-tree traversal and side-view extraction for string construction, assessing data-structure proficiency and algorithmic reasoning.

Part 1: Merge Meeting Intervals

You are given an unsorted list of meeting intervals, where each interval is `[start, end]`. Return the smallest possible list of merged intervals that covers exactly the same occupied time. Two intervals should be merged if they overlap or touch. For this problem, touching means the end of one interval is equal to the start of another, so `[1, 3]` and `[3, 5]` become `[1, 5]`.

Constraints

  • `0 <= len(intervals) <= 200000`
  • `-10^9 <= start <= end <= 10^9`
  • Intervals are closed for merging purposes: if `next_start == current_end`, they merge.

Examples

Input: [[5, 7], [1, 3], [2, 4], [8, 10]]

Expected Output: [[1, 4], [5, 7], [8, 10]]

Explanation: `[1, 3]` and `[2, 4]` overlap, so they merge into `[1, 4]`.

Input: [[1, 3], [3, 5], [6, 8], [7, 9]]

Expected Output: [[1, 5], [6, 9]]

Explanation: `[1, 3]` touches `[3, 5]`, and `[6, 8]` overlaps `[7, 9]`.

Input: []

Expected Output: []

Explanation: No intervals means no occupied time.

Input: [[4, 4]]

Expected Output: [[4, 4]]

Explanation: A single interval is already merged.

Input: [[6, 8], [1, 9], [2, 4], [4, 7]]

Expected Output: [[1, 9]]

Explanation: All intervals overlap directly or indirectly, so they collapse into one interval.

Hints

  1. Sort the intervals by start time before trying to merge anything.
  2. Keep track of the last merged interval and decide whether the next interval extends it or starts a new block.

Part 2: Merge Meeting Intervals with Availability Flags

You are given an unsorted list of intervals, where each interval is `[start, end, is_available]`. Return only the merged time ranges during which the person is unavailable. A time is considered unavailable if it is covered by at least one interval with `is_available == False`, even if some overlapping interval marks that same time as available. Merge unavailable intervals that overlap or touch.

Constraints

  • `0 <= len(intervals) <= 200000`
  • `-10^9 <= start <= end <= 10^9`
  • `is_available` is either `True` or `False`
  • Touching unavailable intervals merge when `next_start == current_end`.

Examples

Input: [[5, 6, True], [1, 3, False], [2, 4, True], [4, 4, False], [6, 8, False], [8, 10, False]]

Expected Output: [[1, 3], [4, 4], [6, 10]]

Explanation: Only intervals marked `False` matter. `[6, 8]` and `[8, 10]` touch and merge.

Input: [[1, 10, True], [3, 4, False]]

Expected Output: [[3, 4]]

Explanation: The larger available interval does not remove the smaller unavailable section.

Input: [[1, 5, False], [2, 3, True], [5, 6, False]]

Expected Output: [[1, 6]]

Explanation: The unavailable intervals `[1, 5]` and `[5, 6]` touch, so they merge into `[1, 6]`.

Input: []

Expected Output: []

Explanation: No intervals means no unavailable time.

Input: [[3, 3, False]]

Expected Output: [[3, 3]]

Explanation: A single unavailable instant remains as is.

Hints

  1. Ask which intervals can possibly contribute to the final answer at all.
  2. Once you isolate the relevant intervals, the rest of the problem becomes the same as standard interval merging.

Part 3: Build a String from Binary-Tree Side Views (Both Bottom to Top)

A binary tree stores one character at each node. The tree is given as a level-order array using heap-style indexing: for a node at index `i`, the left child is at `2*i + 1` and the right child is at `2*i + 2`. Missing nodes are represented by `None`. Return a string formed by: 1. taking the left side view from bottom to top, then 2. appending the right side view from bottom to top, while avoiding duplicates for nodes already included from the left side view. A duplicate means the same tree node appearing in both views, not merely the same character value.

Constraints

  • `0 <= len(values) <= 100000`
  • Each non-`None` entry is a string of length 1
  • The input represents a valid binary tree in heap-style array form
  • If the tree is empty, return an empty string

Examples

Input: (['a', 'b', 'c'],)

Expected Output: 'bac'

Explanation: Left view is a, b so bottom-to-top is ba. Right view is a, c so bottom-to-top is ca. Skip the duplicate root a and append only c, giving bac.

Input: ([],)

Expected Output: ''

Explanation: An empty array means there is no tree, so the result is an empty string.

Input: (['a', 'b', 'b'],)

Expected Output: 'bab'

Explanation: Left bottom-to-top is ba. Right bottom-to-top is ba, but only the root a is the same node. The right-side b is a different node, so it is appended.

Input: (['a', 'b', None, 'c'],)

Expected Output: 'cba'

Explanation: This is a left-skewed tree a -> b -> c. Both side views contain the same nodes, so the left bottom-to-top string cba is the full answer.

Input: (['a', 'b', 'c', 'd', None, None, 'e'],)

Expected Output: 'dbaec'

Explanation: Left view is a, b, d so bottom-to-top is dba. Right view is a, c, e so bottom-to-top is eca. Skip the duplicate root a and append ec, giving dbaec.

Input: ([None, 'a', 'b'],)

Expected Output: ''

Explanation: The root is missing, so there is no reachable tree. Nodes below it are ignored.

Hints

  1. A level-order traversal naturally reveals the first and last visible node at each depth.
  2. Store node positions, not just characters, so you can avoid reusing the same node when combining the views.

Part 4: Build a String from Binary-Tree Side Views (Left Bottom to Top, Right Top to Bottom)

A binary tree stores one character at each node. The tree is given as a level-order array using heap-style indexing: for a node at index `i`, the left child is at `2*i + 1` and the right child is at `2*i + 2`. Missing nodes are represented by `None`. Return a string formed by: 1. taking the left side view from bottom to top, then 2. appending the right side view from top to bottom, while avoiding duplicates for nodes already included from the left side view. A duplicate means the same tree node appearing in both views, not merely the same character value.

Constraints

  • `0 <= len(values) <= 100000`
  • Each non-`None` entry is a string of length 1
  • The input represents a valid binary tree in heap-style array form
  • If the tree is empty, return an empty string

Examples

Input: (['a','b','c','d','e','f','g'],)

Expected Output: "dbacg"

Explanation: Left view is a, b, d, so bottom-to-top gives dba. Right view is a, c, g; skipping a because that node is already used leaves cg. Result: dbacg.

Input: ([],)

Expected Output: ""

Explanation: An empty array represents an empty tree, so the result is an empty string.

Input: (['z'],)

Expected Output: "z"

Explanation: The single root node is in both side views, but it is only included once.

Input: (['a','b',None,'c'],)

Expected Output: "cba"

Explanation: The only reachable nodes are a -> b -> c down the left side. Left view is a, b, c, so bottom-to-top is cba. The right view is the same nodes, so nothing extra is appended.

Input: (['a','b','c','d',None,None,'e'],)

Expected Output: "dbace"

Explanation: Left view is a, b, d, giving dba from bottom to top. Right view is a, c, e; skipping the shared root a leaves ce. Result: dbace.

Input: (['a','b','b','c',None,None,'c'],)

Expected Output: "cbabc"

Explanation: Left view is a, b, c, so bottom-to-top gives cba. Right view is a, b, c on different nodes at depths 1 and 2, so after skipping only the shared root, bc is appended. Equal character values do not count as duplicates if they are different nodes.

Input: ([None,'a','b'],)

Expected Output: ""

Explanation: A missing root means the tree is empty. Deeper array entries are ignored because they are not reachable from index 0.

Hints

  1. Use one breadth-first traversal to collect the leftmost and rightmost node at each level.
  2. The only difference from the previous variant is the order in which you append the right-side view.
Last updated: Apr 26, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ 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.

Related Coding Questions

  • Minimize Travel Assignment Cost - Bloomberg (medium)
  • Determine Balloon Popping Time - Bloomberg (medium)
  • Check connectivity between two subway stations - Bloomberg (easy)
  • Minimize travel cost with two cities - Bloomberg (easy)
  • Design a data structure for dynamic top‑K frequency - Bloomberg (hard)