NewProject Coding is here — build features and fix bugs in real codebases with an AI assistantSee what's new

A cloud provider needs to schedule a new computing task on one of its available server hubs. Your goal is to design an algorithm that selects the most efficient hub for the job based on capacity and availability.

You are given n hubs, indexed from 0 to n - 1. You are provided with the following information:

  • An integer array capacities of length n, where capacities[i] is the total processing capacity of hub i.
  • A 2D array of strings intervals, where intervals[i] contains a list of strings representing time intervals already booked on hub i. Each interval is a string in the format "start:end", indicating a booking from start to end (inclusive).
  • An integer requiredCapacity, which is the processing capacity needed for the new task.
  • A string taskInterval in the format "start:end", representing the start and end time for the new task, inclusive.
Test Cases
Input
Output
Expected