Problem · Design

User Quota Scheduling with Expiring Assignments

MediumCircleFULLTIMEOA

Complete the function below. The function receives the full standard input as a single string and must return the exact standard output lines for the described problem.

Original prompt

Problem: User Quota Scheduling with Expiring Assignments (Level 3)

Implement a user/task scheduling system.

Requirements

Create user: each user has a quota meaning the maximum number of concurrent assignments allowed for that user. Assign a task: assign to a user a time interval [startTime, endTime) with a taskId.

Rules

Each assignment is active on the half-open interval [startTime, endTime). Once endTime is reached, the assignment expires and no longer counts toward the user’s concurrent quota. Example: existing assignment [4,10) no longer counts for any t >= 10. If adding a new assignment would make the number of concurrent active assignments exceed quota at any time, the assignment must be rejected.

Output

For each assignment attempt, output whether it succeeds (e.g., true/false or OK/FAIL per spec).

Constraints

Potentially large, but OA tests may be small; a straightforward approach may pass. Test ideas quota=1: add [4,10) ok; add [10,12) ok. quota=1: add [4,10) ok; add [9,12) reject. quota=2: adding a third overlapping interval should reject. Edge: zero-length intervals (per spec). Multiple users are independent.

Function Description

Complete solveUserQuotaScheduling. It has one parameter, String input, containing the full stdin payload. Return the stdout payload as an array of lines, without trailing newline characters.

Examples
01 · Example 1
input = "CREATE_USER u1 1\nASSIGN u1 1 4 10\nASSIGN u1 2 10 12"
return = ["OK", "OK"]

The returned string must match the expected standard output for the sample input.

Constraints

Use the limits and requirements stated in the prompt.

More Circle problems
drafts saved locally
public String[] solveUserQuotaScheduling(String input) {
    // write your code here
}
input"CREATE_USER u1 1\nASSIGN u1 1 4 10\nASSIGN u1 2 10 12"
expected["OK", "OK"]
sign in to submit