Activity Selection Problems

I didn’t get the question of how the number of activities is calculated in Sample input. Please explain to me the problems statement

Suppose each activity has a start and end time, i.e if you choose to do that activity then you will be engaged in doing that activity in the time interval [start,end], and obviously you can not do any other activity in this period. So now from given n activities with given start and end times, choose maximum number of activities you can do.

Sample Input
1
3
10 20
12 15
20 30

Choose activity 2 and 3, and you will be busy in time interval [12,15] and [20,30], thus you can do both without any clashes, but you can not do activity 1 now, as it will require [10,20] time, but you already have to do activity 2 in [12,15].

Thus maximum no. of activities you can do are 2, namely activity 2 and activity 3.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.