René's URL Explorer Experiment


Title: #659 - Split Array into Consecutive Subsequences - LeetCode JavaScript Solutions

Open Graph Title: #659 - Split Array into Consecutive Subsequences - LeetCode JavaScript Solutions

X Title: #659 - Split Array into Consecutive Subsequences - LeetCode JavaScript Solutions

Description: You are given an integer array nums that is sorted in non-decreasing order. Determine if it is possible to split nums into one or more subse...

Open Graph Description: You are given an integer array nums that is sorted in non-decreasing order. Determine if it is possible to split nums into one or more subse...

X Description: You are given an integer array nums that is sorted in non-decreasing order. Determine if it is possible to split nums into one or more subse...

Keywords:

Opengraph URL: https://leetcodejavascript.com/solutions/split-array-into-consecutive-subsequences

direct link

Domain: leetcodejavascript.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"Code","url":"https://leetcodejavascript.com/solutions/split-array-into-consecutive-subsequences","name":"#659 - Split Array into Consecutive Subsequences - LeetCode JavaScript Solutions","description":"You are given an integer array nums that is sorted in non-decreasing order. Determine if it is possible to split nums into one or more subse...","programmingLanguage":"JavaScript","codeRepository":"https://github.com/JoshCrozier/leetcode-javascript","codeSampleType":"JavaScript","text":"/**\n * @param {number[]} nums\n * @return {boolean}\n */\nvar isPossible = function(nums) {\n const map = new Map();\n const map2 = new Map();\n\n for (const n of nums) {\n map.set(n, (map.get(n) || 0) + 1);\n }\n\n for (const n of nums) {\n if (map.get(n) === 0) continue;\n\n if ((map2.get(n) || 0) > 0) {\n map2.set(n, map2.get(n) - 1);\n map.set(n, map.get(n) - 1);\n map2.set(n + 1, (map2.get(n + 1) || 0) + 1);\n } else if ((map.get(n) || 0) > 0 && (map.get(n + 1) || 0) > 0 && (map.get(n + 2) || 0) > 0) {\n map.set(n, map.get(n) - 1);\n map.set(n + 1, map.get(n + 1) - 1);\n map.set(n + 2, map.get(n + 2) - 1);\n map2.set(n + 3, (map2.get(n + 3) || 0) + 1);\n } else {\n return false;\n }\n }\n\n return true;\n};","keywords":"LeetCode 659, #659 - Split Array into Consecutive Subsequences, 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/split-array-into-consecutive-subsequences
twitter:imagehttps://leetcodejavascript.com/og-image.jpg
twitter:creator@joshcrozier
theme-color#1f2937

Links:

LeetCodeJavascript.com https://leetcodejavascript.com/
Star on GitHubhttps://github.com/JoshCrozier/leetcode-javascript
Back to all solutionshttps://leetcodejavascript.com
View on LeetCode https://leetcode.com/problems/split-array-into-consecutive-subsequences/
View on GitHubhttps://github.com/JoshCrozier/leetcode-javascript/blob/master/solutions/0659-split-array-into-consecutive-subsequences.js
Array https://leetcodejavascript.com/tags/array
Hash Table https://leetcodejavascript.com/tags/hash-table
Greedy https://leetcodejavascript.com/tags/greedy
Heap Priority Queuehttps://leetcodejavascript.com/tags/heap-priority-queue
Josh Crozierhttps://joshcrozier.com

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

Robots: index, follow


URLs of crawlers that visited me.