Skip to content
CampusEduX

Activity Selection

Mediumjavapythonccppjavascript

Given N activities with start and finish times, select the maximum number of activities that can be performed by a single person, where a person can only work on one activity at a time. An activity may start exactly when another finishes.

Input Format

The first line contains an integer N. Each of the next N lines contains two integers start and finish (start <= finish).

Output Format

Print the maximum number of non-overlapping activities.

Related Problems

  • Fractional Knapsack
    Medium · java, python, c, cpp, javascript
    Solve Problem
  • Minimum Number of Coins
    Medium · java, python, c, cpp, javascript
    Solve Problem
  • Minimum Platforms
    Medium · java, python, c, cpp, javascript
    Solve Problem

Input (stdin)

Output

Run your code to see output here...