← 返回 snowflake 的题目列表Maximum Profit in Job Scheduling
类型:qbank
You are given n jobs where every job is represented by three arrays: startTime, endTime, and profit.
Maximum Profit in Job Scheduling
You are given n jobs where every job is represented by three arrays: startTime, endTime, and profit.
SWE
dp
interval
binary-search
sorting
hard
Frequency
Single report
Last asked
2026-01-07
Stage
phone-screen · onsite-coding
Maximum Profit in Job Scheduling
Problem Requirements
You are provided with n jobs. Each job has three specific details given in arrays: startTime, endTime, and profit.
For a specific job i:
It begins at startTime[i].
It finishes at endTime[i].
It earns you profit[i].
Your goal is to choose a group of jobs that do not overlap in time. You want to select the combination that results in the highest possible total profit.
Timing Rule: If one job finishes exactly at time x, you are allowed to start the next job at time x.
You must return the maximum profit value you can get.
Test Cases
Case 1:
Input: startTime = [1,2,3,3], endTime = [3,4,5,6], profit = [50,10,40,70]
Output: 120
Case 2:
Input: startTime = [1,2,3,4,6], endTime = [3,5,10,6,9], profit = [20,20,100,70,60]
Output: 150
Data Limits
The number of jobs (length of the arrays) is between 1 and 5 * 10^4.
All three arrays (startTime, endTime, profit) have the same length.
Time values are between 1 and 10^9.
A job's start time is always less than its end time.
The profit for a single job is between 1 and 10^4.