Interval Scheduling Problem Leetcode Two Sum Javascript Solution