1
var maxTwoEvents = function (events) {2
const n = events.length;4
events.sort((a, b) => a[0] - b[0]);6
const minHeap = new MinPriorityQueue({ priority: (x) => x[1] });11
for (let i = 0; i < n; ++i) {12
const [currStart, currEnd, currVal] = events[i];14
while (!minHeap.isEmpty()) {15
const topElement = minHeap.front().element;16
const [topIdx, topEnd] = topElement;18
if (topEnd < currStart) {19
maxVal = Math.max(maxVal, events[topIdx][2]);26
const sum = maxVal + currVal;27
maxSum = Math.max(maxSum, sum);28
minHeap.enqueue([i, currEnd]);