Activity selection problem

https://ide.codingblocks.com/s/363890 plz check where i have mistaken and suggest correct solution to the problem.

hello @avverma11057
a)ur k will contain garbage value initially. which may create issue
b) the input is not sorted , so u need to sort ur array first before applying logic.

here is the logic->
A basic activity selection problem which uses Greedy approach. The implementation mentioned here states to sort the activities in the increasing order of their finishing times. Initially, we choose the first activity. Now, starting from second activity, current activity can be selected if the finish time of previous selected activity is less than or equal to the starting time of current activity

code->

sir can you please give me a written code. if possilbe plz send i am unable to uderstand

@avverma11057
pls check my last response, i have already attached the code with it

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.