René's URL Explorer Experiment


Title: #1146 - Snapshot Array - LeetCode JavaScript Solutions

Open Graph Title: #1146 - Snapshot Array - LeetCode JavaScript Solutions

X Title: #1146 - Snapshot Array - LeetCode JavaScript Solutions

Description: Implement a SnapshotArray that supports the following interface: SnapshotArray(int length) initializes an array-like data structure with th...

Open Graph Description: Implement a SnapshotArray that supports the following interface: SnapshotArray(int length) initializes an array-like data structure with th...

X Description: Implement a SnapshotArray that supports the following interface: SnapshotArray(int length) initializes an array-like data structure with th...

Keywords:

Opengraph URL: https://leetcodejavascript.com/solutions/snapshot-array

direct link

Domain: leetcodejavascript.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"Code","url":"https://leetcodejavascript.com/solutions/snapshot-array","name":"#1146 - Snapshot Array - LeetCode JavaScript Solutions","description":"Implement a SnapshotArray that supports the following interface: SnapshotArray(int length) initializes an array-like data structure with th...","programmingLanguage":"JavaScript","codeRepository":"https://github.com/JoshCrozier/leetcode-javascript","codeSampleType":"JavaScript","text":"/**\n * @param {number} length\n */\nvar SnapshotArray = function(length) {\n this.history = new Map();\n this.snapshots = 0;\n this.length = length;\n};\n\n/**\n * @param {number} index\n * @param {number} val\n * @return {void}\n */\nSnapshotArray.prototype.set = function(index, val) {\n const current = this.history.get(this.snapshots) || new Map();\n current.set(index, val);\n this.history.set(this.snapshots, current);\n};\n\n/**\n * @return {number}\n */\nSnapshotArray.prototype.snap = function() {\n return this.snapshots++;\n};\n\n/**\n * @param {number} index\n * @param {number} snapId\n * @return {number}\n */\nSnapshotArray.prototype.get = function(index, snapId) {\n for (let id = snapId; id >= 0; id--) {\n const snapshot = this.history.get(id);\n if (snapshot && snapshot.has(index)) {\n return snapshot.get(index);\n }\n }\n return 0;\n};","keywords":"LeetCode 1146, #1146 - Snapshot Array, 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/snapshot-array
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/snapshot-array/
View on GitHubhttps://github.com/JoshCrozier/leetcode-javascript/blob/master/solutions/1146-snapshot-array.js
Array https://leetcodejavascript.com/tags/array
Hash Table https://leetcodejavascript.com/tags/hash-table
Binary Search https://leetcodejavascript.com/tags/binary-search
Designhttps://leetcodejavascript.com/tags/design
Josh Crozierhttps://joshcrozier.com

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

Robots: index, follow


URLs of crawlers that visited me.