Sort all jobs by their end times. For each job, you face a binary choice: skip it or take it.
If you skip job , the best profit stays the same. If you take it, you earn its profit plus the best profit from all jobs that finish before job starts. Since jobs are sorted by end time, binary search finds that latest non-conflicting job fast.
This gives you a recurrence: dp[i] = max(dp[i-1], profit[i] + dp[lastNonConflicting(i)]). Each dp[i] stores the best profit from the first jobs. The answer is dp[n].
Greedy fails here because one high-profit job might block several smaller jobs whose combined profit exceeds it. You need to evaluate both paths at each step.