René's URL Explorer Experiment


Title: #18 - 4Sum - LeetCode JavaScript Solutions

Open Graph Title: #18 - 4Sum - LeetCode JavaScript Solutions

X Title: #18 - 4Sum - LeetCode JavaScript Solutions

Description: Given an array nums of n integers, return an array of all the unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that: 0 <= a,...

Open Graph Description: Given an array nums of n integers, return an array of all the unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that: 0 <= a,...

X Description: Given an array nums of n integers, return an array of all the unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that: 0 <= a,...

Keywords:

Opengraph URL: https://leetcodejavascript.com/solutions/4sum

direct link

Domain: leetcodejavascript.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"Code","url":"https://leetcodejavascript.com/solutions/4sum","name":"#18 - 4Sum - LeetCode JavaScript Solutions","description":"Given an array nums of n integers, return an array of all the unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that:  0 <= a,...","programmingLanguage":"JavaScript","codeRepository":"https://github.com/JoshCrozier/leetcode-javascript","codeSampleType":"JavaScript","text":"/**\n * @param {number[]} nums\n * @param {number} target\n * @return {number[][]}\n */\nvar fourSum = function(nums, target) {\n  const result = [];\n\n  nums.sort((a, b) => a - b);\n\n  for (let i = 0; i < nums.length - 3; i++) {\n    for (let j = i + 1; j < nums.length - 2; j++) {\n      let high = nums.length - 1;\n      let low = j + 1;\n\n      while (low < high) {\n        const sum = nums[i] + nums[j] + nums[low] + nums[high];\n\n        if (sum === target) {\n          result.push([nums[i], nums[j], nums[low], nums[high]]);\n          while (nums[low] === nums[low + 1]) {\n            low++;\n          }\n          while (nums[high] === nums[high - 1]) {\n            high--;\n          }\n          low++;\n          high--;\n        } else if (sum < target) {\n          low++;\n        } else {\n          high--;\n        }\n      }\n      while (nums[j] === nums[j + 1]) {\n        j++;\n      }\n    }\n    while (nums[i] === nums[i + 1]) {\n      i++;\n    }\n  }\n\n  return result;\n};","keywords":"LeetCode 18, #18 - 4Sum, 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/4sum
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/4sum/
View on GitHub https://github.com/JoshCrozier/leetcode-javascript/blob/master/solutions/0018-4sum.js
Array https://leetcodejavascript.com/tags/array
Sorting https://leetcodejavascript.com/tags/sorting
Two Pointers https://leetcodejavascript.com/tags/two-pointers
Josh Crozierhttps://joshcrozier.com

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

Robots: index, follow


URLs of crawlers that visited me.