René's URL Explorer Experiment


Title: #715 - Range Module - LeetCode JavaScript Solutions

Open Graph Title: #715 - Range Module - LeetCode JavaScript Solutions

X Title: #715 - Range Module - LeetCode JavaScript Solutions

Description: A Range Module is a module that tracks ranges of numbers. Design a data structure to track the ranges represented as half-open intervals and...

Open Graph Description: A Range Module is a module that tracks ranges of numbers. Design a data structure to track the ranges represented as half-open intervals and...

X Description: A Range Module is a module that tracks ranges of numbers. Design a data structure to track the ranges represented as half-open intervals and...

Keywords:

Opengraph URL: https://leetcodejavascript.com/solutions/range-module

direct link

Domain: leetcodejavascript.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"Code","url":"https://leetcodejavascript.com/solutions/range-module","name":"#715 - Range Module - LeetCode JavaScript Solutions","description":"A Range Module is a module that tracks ranges of numbers. Design a data structure to track the ranges represented as half-open intervals and...","programmingLanguage":"JavaScript","codeRepository":"https://github.com/JoshCrozier/leetcode-javascript","codeSampleType":"JavaScript","text":"var RangeModule = function() {\n  this.ranges = [];\n};\n\n/**\n * @param {number} left\n * @param {number} right\n * @return {void}\n */\nRangeModule.prototype.addRange = function(left, right) {\n  const intervals = [];\n  let placed = false;\n  for (const [start, end] of this.ranges) {\n    if (start > right && !placed) {\n      intervals.push([left, right]);\n      placed = true;\n    }\n    if (end < left || start > right) {\n      intervals.push([start, end]);\n    } else {\n      left = Math.min(left, start);\n      right = Math.max(right, end);\n    }\n  }\n  if (!placed) intervals.push([left, right]);\n  this.ranges = intervals;\n};\n\n/**\n * @param {number} left\n * @param {number} right\n * @return {boolean}\n */\nRangeModule.prototype.queryRange = function(left, right) {\n  for (const [start, end] of this.ranges) {\n    if (start <= left && end >= right) return true;\n    if (start > left) break;\n  }\n  return false;\n};\n\n/**\n * @param {number} left\n * @param {number} right\n * @return {void}\n */\nRangeModule.prototype.removeRange = function(left, right) {\n  const intervals = [];\n  for (const [start, end] of this.ranges) {\n    if (end <= left || start >= right) {\n      intervals.push([start, end]);\n    } else {\n      if (start < left) intervals.push([start, left]);\n      if (end > right) intervals.push([right, end]);\n    }\n  }\n  this.ranges = intervals;\n};","keywords":"LeetCode 715, #715 - Range Module, Hard, 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/range-module
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/range-module/
View on GitHub https://github.com/JoshCrozier/leetcode-javascript/blob/master/solutions/0715-range-module.js
Design https://leetcodejavascript.com/tags/design
Ordered Set https://leetcodejavascript.com/tags/ordered-set
Segment Tree https://leetcodejavascript.com/tags/segment-tree
Josh Crozierhttps://joshcrozier.com

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

Robots: index, follow


URLs of crawlers that visited me.