Please tell what is the problem in this code for Activity Selection Problem

hello @sahilkhan2312000131 please wait let me go through your code .
btw what is the problem that you are facing ?

What I have done is I have stored the data in n*2 array. For each set of element, I am checking that if first element of this set is greater than second element of any of the remaining sets then I increase the ptr else if second element of this set is less than the first element of the remaining sets then also I increase the ptr value. I do this for each set and the value of ptr which is max for any set then it is my answer.

hello @sahilkhan2312000131 your logic is somewhere correct but you have unnecessarily made this question complex .
see as you have understood the task that if the starting time of the task is greater then the ending time of the previous task then you can perform this task .
that why you can simply do its coding by making a vector of type pair and then sorting the vector on the basis of the ending time and then you can check your condition .
here for your reference i am attaching the code :
https://ide.codingblocks.com/s/365487
if you dont understand anything please let me know .
Happy Learning !!

Thank u so much @tusharaggarwal272