I'm getting segmentation fault but code is running fine in my ide

you need to sort by ending time not the starting time
Corrected Code with comments
https://ide.codingblocks.com/s/307337