Finished algo to find longest interval in interval set