Didn't get the approach to do the question

Please tell the approach to solve this question.

@riya17,
You just have to think greedily, in fact you could imagine it as a real life scenario. You have to do n number of tasks, each with allocated starting and ending times, so naturally, you would want to prioritise tasks, which begin and and end as early as possible, so that after doing those tasks, you still have significant time left in the day.
Apply the same here, greedily choose tasks.

Hello @riya17, my fellow TA has told the approach. And yes it is correct.
This is one of the famous ques of greedy approach.
Algo :-
Take the input for the start and end time
And sort the activities based on the ending time (sort in a way such that the job finishes the first)
And after that start selecting the first job and set its end time as the start for the next job. Pls try a little on paper pen this logic.
And if still any issue or confusion is there pls let me know. I will try my best to help you out !!

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.