WHY THIS IS GIVING WRONG ANSWER FOR THIS QUESTION,
I AM JUST TRYING THAT IF ONE ACTIVITY ENDS THEN IT WILL SELECT AUTOMATICALLY THE ACTIVITY THAT STARTING TIME OF NEXT activity WILL BE GREATER OR EQUAL TO PREVIOUS ONE.
ok .
u need to consider following things
a)
so first u need to sort ur activities on the basis of ending time . to make all activities in order.
b) u need to keep track of last picked activity and then compare it with current acticity . if they are not colliding then include current and update ur last picked with current.
can we do this without pairs?
yeah we can , using pairs make sorting easy.
otherwise we need to write our own sort function to consider both array for starting and ending times
do knowledge of vectors are required?
no , u can make array of pairs
like this->
pair<int,int> arr[n];
still it is giving one case wrong?
use different variable for reading size of array
thank you very much my doubt is solved.
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.