What's wrong with my code

This is the link to my code for this problem – https://ide.codingblocks.com/s/334443
I’m getting the correct output for a lot of sample inputs that I tried from my side, but the code is not submitting.
Please help me spot out the discrepancy in this code.

Hey @chaturvedia336
Failing for simple tc like this:
1
2
2 4
1 2

sort the array in increasing order of end times and it ill work fine :slight_smile:

Here is the code with the additional changes made – https://ide.codingblocks.com/s/334443 . One test case is still failing

Hey @chaturvedia336
Replace line 21 by :

for(int j =0; j<(n-i-1); j++){ //<= nhi only <

Hey @chaturvedia336
If this is resolved then please mark it so:)