In some problems like scheduling of times where starting and ending times(or position) is given and we need to find the maximum value. how to ensure with which value is to be sorted?
Ex. Merge Overlapping Interval
Trains scheduling questions
Maximum jobs among distribution among two person.
When to sort a pair according to starting point and when with ending points
Hello @abhir26,
The choice depends upon the requirement of the question.
To understand this better I would suggest you, rewatch all the videos and understand what would happen if you would use starting point instead of ending or vice-a-versa.
So, there is no fixed rule.
It’s the requirement of the question that leads us to that solution.
Try to understand the reason why wouldn’t we choose the other point to sort.
Hope, this would help.
Yes I agree that it depends on the question, but still I can’t identify. for example in the Google codejam qualification round 2020, there was a question “Parenting Partnering Returns”, this can’t be solved using end points, didn’t understand why.
@abhir26
you might have done some mistake in ur implementation.
that problem is solved by sorting activities on the basis of ending time.( you can check others submission to know what u did wrong ).
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.