Data Structures & Algorithms Master Level Finale
💡
Exercise 161

Max Profit in Job Schedule 30 XP Hard

LeetCode Ctrl+Enter Run Ctrl+S Save

Given jobs with [startTime, endTime, profit], find the maximum profit from non-overlapping jobs. Combines sorting + binary search + DP.

Sort by end time. For each job, binary search for the latest non-overlapping previous job. dp[i] = max(dp[i-1], profit[i] + dp[last_non_overlapping]).

💡 Pro tip: Understand this problem deeply — don't just memorize the code. Try explaining the approach out loud as if teaching a friend. If you can explain it simply, you truly understand it!

📋 Instructions
Find max profit from the given jobs.
Sort by end time. Use bisect to find latest job ending before current start. DP transition: take or skip.
🧪 Test Cases
Input
jobScheduling([1,2,3,3],[3,4,5,6],[50,10,40,70])
Expected
120
Test case 1
main.py
Hi! I'm Rex 👋
Output
Ready. Press ▶ Run or Ctrl+Enter.