please provide me the basic idea of doing this problem.
Activity Selection Problem
The greedy choice is to always pick the next activity whose finish time is least among the remaining activities and the start time is more than or equal to the finish time of previously selected activity. We can sort the activities according to their finishing time so that we always consider the next activity as minimum finishing time activity.
Approach
- Sort the activities according to their finishing time
- Select the first activity from the sorted array and print it.
- Do following for remaining activities in the sorted array.
a) If the start time of this activity is greater than or equal to the finish time of previously selected activity then select this activity and print it.
still getting wrong answer, although passed the sample test case.
send me link of code
i will see what are the mistakes
modified Code
link is not working…did you fix the code on the same link?
please check now !!
i have updated the link
j-1 is same as (chosen =0; chosen=j;)?
no both are different
you have to skip some activities in between two activities