I am not able to pass the second test case

Are you getting TLE or Wrong answer for test case 2?

i am getting wrong answer

Check for this test case

1
25
37 45 
75 76
76 91
64 78
10 53
13 24
94 99
89 92
82 84
77 87
65 73
55 77
43 99
32 37
90 95
30 53
97 99
77 91
93 99
13 64
26 51
7 39
31 50
11 14
33 79

Expected output is 8
Yours is giving 5

okay , then i must spend some more time on it

can you explain me the problem,whether it wants max activities or activies that combines to give max time

You are doing this problem with a naive approach. There’s a better solution for this problem in O(NlogN) time

You have to do maximum number of activities that can be performed by a single person, assuming that a person can only work on a single activity at a time.
Read this Editorial
If have any other doubts left in it, ask me

if i read the editorial ,will marks be deducted

It’s not the editorial of coding blocks. Read it without any hesitation.

1 Like

all test cases passed now,earlier the mistake was that i was sorting the pair by comparing their start time instead of end time
but my solution is still in O(N^2)
can you edit it for (NlogN)

See this , this solution is O(nlogn)

1 Like

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.

1 Like