[QABANK] Calendar Busy View
Problem Description:
Summary: Given list of events of a given day in a calendar, write an algorithm to return a list
of busy view time slots. Busy view is created by consolidating adjacent and overlapping event
time slots without showing details of individual events.
Details: Each event in calendar has a start time, end time & some title. Events can start at
any minute (granularity at the minute only, no seconds).
Sample inputs - Expected outputs
Input: list of following events
(100,300,"Some Event") // 1:00 am to 3:00 am
(115,145,"Some Event")
(145,215,"Some Event")
(200,400,"Some Event")
(215,230,"Some Event")
(215,415,"Some Event")
(600,700,"Some Event")
(500,600,"Some Event")
Output: Based on above events, my busy view should show like this:
(100,415) // Busy from 1am to 4:15am
(500,700) // Busy from 5am to 7am
This question asks you to merge overlapping and adjacent calendar intervals to produce a“busy view.”The key is to sort all intervals by start time and then sweep through them, merging when the next event starts before (or exactly at) the current merged interval’s end.
Bloomberg Interview Question: Identify the First Process That Crashed
An operating system has the following rules:
1. Each process is spawned from a parent process except the first process.
2. The parent process is aware of its children.
3. If a parent process is aborted, all the child processes get aborted.
One of the processes crashed and brought down a lot of other processes along with it.
A log parser found the set of all the processes which have crashed. This set of processes,
along with sub-process child relationships for each process, is then passed to your function.
Identify the id of the process which crashed first.
Example tree:
15
/ \
7 5
/ \ \
9 4 1
/ \
2 11
Input:
[
Process(9, [2,11]),
Process(11, []),
Process(4, []),
Process(7, [9,4]),
Process(2, []),
]
Output: 7
You are given a subset of crashed processes and their child relationships. Since a parent’s failure recursively kills all its descendants, the earliest crash must be the highest ancestor in the crashed-subgraph. This reduces to finding the root of the crashed subtree: a crashed process whose parent is not in the crashed set.