René's URL Explorer Experiment


Title: #1834 - Single-Threaded CPU - LeetCode JavaScript Solutions

Open Graph Title: #1834 - Single-Threaded CPU - LeetCode JavaScript Solutions

X Title: #1834 - Single-Threaded CPU - LeetCode JavaScript Solutions

Description: You are given n tasks labeled from 0 to n - 1 represented by a 2D integer array tasks, where tasks[i] = [enqueueTimei, processingTimei] mean...

Open Graph Description: You are given n tasks labeled from 0 to n - 1 represented by a 2D integer array tasks, where tasks[i] = [enqueueTimei, processingTimei] mean...

X Description: You are given n tasks labeled from 0 to n - 1 represented by a 2D integer array tasks, where tasks[i] = [enqueueTimei, processingTimei] mean...

Keywords:

Opengraph URL: https://leetcodejavascript.com/solutions/single-threaded-cpu

direct link

Domain: leetcodejavascript.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"Code","url":"https://leetcodejavascript.com/solutions/single-threaded-cpu","name":"#1834 - Single-Threaded CPU - LeetCode JavaScript Solutions","description":"You are given n tasks labeled from 0 to n - 1 represented by a 2D integer array tasks, where tasks[i] = [enqueueTimei, processingTimei] mean...","programmingLanguage":"JavaScript","codeRepository":"https://github.com/JoshCrozier/leetcode-javascript","codeSampleType":"JavaScript","text":"/**\n * @param {number[][]} tasks\n * @return {number[]}\n */\nvar getOrder = function(tasks) {\n  const indexedTasks = tasks.map(([enqueue, process], index) => ({ enqueue, process, index }))\n    .sort((a, b) => a.enqueue - b.enqueue);\n\n  const result = [];\n  const availableTasks = new PriorityQueue((a, b) => a.process - b.process || a.index - b.index);\n  let currentTime = indexedTasks[0].enqueue;\n  let taskIndex = 0;\n\n  while (result.length < tasks.length) {\n    while (taskIndex < tasks.length && indexedTasks[taskIndex].enqueue <= currentTime) {\n      availableTasks.push(indexedTasks[taskIndex]);\n      taskIndex++;\n    }\n\n    if (availableTasks.size() > 0) {\n      const task = availableTasks.pop();\n      result.push(task.index);\n      currentTime += task.process;\n    } else {\n      currentTime = indexedTasks[taskIndex].enqueue;\n    }\n  }\n\n  return result;\n};","keywords":"LeetCode 1834, #1834 - Single-Threaded CPU, Medium, JavaScript solution","learningResourceType":"Code","isAccessibleForFree":true,"educationalLevel":"intermediate","interactivityType":"mixed"}

authorLeetCodeJavascript.com
og:typearticle
og:imagehttps://leetcodejavascript.com/og-image.jpg
og:site_nameLeetCode JavaScript Solutions
twitter:cardsummary_large_image
twitter:urlhttps://leetcodejavascript.com/solutions/single-threaded-cpu
twitter:imagehttps://leetcodejavascript.com/og-image.jpg
twitter:creator@joshcrozier
theme-color#1f2937

Links:

LeetCodeJavascript.com https://leetcodejavascript.com/
Star on GitHub https://github.com/JoshCrozier/leetcode-javascript
Back to all solutions https://leetcodejavascript.com
View on LeetCode https://leetcode.com/problems/single-threaded-cpu/
View on GitHub https://github.com/JoshCrozier/leetcode-javascript/blob/master/solutions/1834-single-threaded-cpu.js
Array https://leetcodejavascript.com/tags/array
Sorting https://leetcodejavascript.com/tags/sorting
Heap Priority Queue https://leetcodejavascript.com/tags/heap-priority-queue
Josh Crozierhttps://joshcrozier.com

Viewport: width=device-width, initial-scale=1.0

Robots: index, follow


URLs of crawlers that visited me.