You are given two independent coding problems.
You are asked to schedule meetings in a single meeting room.
You are given an array of meeting requests. Each request is represented as a tuple:
start
: integer start time (inclusive)
end
: integer end time (exclusive), with
end > start
priority
: an integer representing the importance / value of that meeting
No two meetings can overlap in time in the single room. Your goal is to choose a subset of non-overlapping meetings to maximize the sum of priorities.
Write a function with the following signature (language-agnostic):
that returns the maximum possible total priority.
Example
Input:
One optimal schedule is to pick meetings (1,3,4) and (3,5,2) for a total priority of 4 + 2 = 6.
Another choice, (0,6,7), has total priority 7, which is better, so the answer is 7.
Constraints
1 <= n <= 2 * 10^5
where
n
is the number of meetings
0 <= start < end <= 10^9
-10^4 <= priority <= 10^4
(priorities can be non‑positive; you may choose to skip such meetings)
meetings
is given as a list/array in arbitrary order.
Describe the algorithm and then implement the function.
You are controlling a vacuum cleaning robot in a 2D grid room. The room is divided into 1x1 cells. Each cell is either empty or blocked. The robot:
You are given the following interface:
The robot is initially facing up (towards negative y direction in some internal coordinate system you choose).
You must implement a function:
that makes the robot clean all reachable empty cells. You cannot:
You can:
(0,0)
).
Constraints and assumptions
Design an algorithm and implement cleanRoom(Robot robot) to guarantee that all reachable empty cells are cleaned.