easy

Activity Selection

You are given n activities, each with a start and finish time, and a single resource that can host one activity at a time. Select the maximum number of activities that do not overlap in time.

Constraints
  • 1 ≤ n ≤ 10^5
  • 0 ≤ start < finish ≤ 10^9
Examples
in: start = [1,3,0,5,8,5], finish = [2,4,6,7,9,9]
out: 4
Activities ending at 2, 4, 7, 9.

Code it yourself

Solve in
Test execution is not yet available for this exercise.Practice journal →Draft saved in this browser.
Hints:
Which approach applies?

Choose an approach to check your pattern recognition, or reveal the discussion when you need help.