n
      // floating point errors increasingly come into play.
      if (sortedTasks[i - 1].end > sortedTasks[i].start) {
        const midpoint = (sortedTasks[i - 1].end + sortedTasks[i].start) / 2;
        sortedTasks[i - 1].end = midpoint;
        sortedTasks[i].start = midpoint;
      }
    }

    // Collect all time points that the sliding window needs to stop at.
    // See https://goo.gl/jmWpMl for justification.
    let endpoints = [];
    endpoints.push(startTime);
    endpoints.push(endTime - windo