Maximum Profit in Job Scheduling

Hard
ArrayBinary SearchDynamic ProgrammingSortingGoogleAmazon
You are given n jobs, each with a start time, an end time, and a profit. Choose a subset of non-overlapping jobs to maximize total profit. A job that ends at time t does not overlap a job that starts at time t. Print the maximum profit. Input format: - First line: n - Next n lines: start end profit

Constraints

1 <= n <= 10^5
1 <= start < end <= 10^9
1 <= profit <= 10^9
The answer fits in a signed 64-bit integer.

Sample tests

Sample 1

Sample 2

Sign in to submit