Interval Scheduling Problem Leetcode Javascript Question