You are asked to solve two algorithmic problems.
Part A: Meeting-room scheduling (intervals)
You are given an array of meeting time intervals intervals, where each interval is [start, end) with 0 <= start < end.
-
Attend-all check
: Return
true
if a single person can attend all meetings (i.e., no overlaps), else
false
.
-
Minimum rooms
: Return the minimum number of conference rooms required to host all meetings.
-
Room assignment / most-used room (optional extension)
: You have
n
rooms labeled
0..n-1
. Schedule meetings in start-time order using the lowest-index available room; if none are available at a meeting’s start, delay the meeting until the earliest room becomes free (preserving meeting duration). Return the room index that hosted the most meetings (tie → smallest index).
Constraints (assume)
-
1 <= intervals.length <= 2e5
-
Times are integers up to
1e9
Part B: Shortest path in a weighted directed graph
Given a weighted directed graph with V nodes labeled 0..V-1 and E edges. Each edge is (u, v, w) with w > 0.
-
Input:
V
, edge list,
source s
,
target t
.
-
Output: the shortest distance from
s
to
t
(and optionally the actual path). If
t
is unreachable, return
-1
.
Constraints (assume)
-
1 <= V <= 2e5
,
0 <= E <= 2e5
-
Weights are positive integers.