Why I'm getting wrong answer?

do I need to sort the input using pair before calculating the activities?

@uthyasani
hello pushpita,
yeah u need to sort the input pairs on the basis of their ending time