Title: #939 - Minimum Area Rectangle - LeetCode JavaScript Solutions
Open Graph Title: #939 - Minimum Area Rectangle - LeetCode JavaScript Solutions
X Title: #939 - Minimum Area Rectangle - LeetCode JavaScript Solutions
Description: You are given an array of points in the X-Y plane points where points[i] = [xi, yi]. Return the minimum area of a rectangle formed from thes...
Open Graph Description: You are given an array of points in the X-Y plane points where points[i] = [xi, yi]. Return the minimum area of a rectangle formed from thes...
X Description: You are given an array of points in the X-Y plane points where points[i] = [xi, yi]. Return the minimum area of a rectangle formed from thes...
Keywords:
Opengraph URL: https://leetcodejavascript.com/solutions/minimum-area-rectangle
Domain: leetcodejavascript.com
{"@context":"https://schema.org","@type":"Code","url":"https://leetcodejavascript.com/solutions/minimum-area-rectangle","name":"#939 - Minimum Area Rectangle - LeetCode JavaScript Solutions","description":"You are given an array of points in the X-Y plane points where points[i] = [xi, yi]. Return the minimum area of a rectangle formed from thes...","programmingLanguage":"JavaScript","codeRepository":"https://github.com/JoshCrozier/leetcode-javascript","codeSampleType":"JavaScript","text":"/**\n * @param {number[][]} points\n * @return {number}\n */\nvar minAreaRect = function(points) {\n const pointSet = new Set(points.map(([x, y]) => `${x},${y}`));\n let result = 0;\n\n for (let i = 0; i < points.length; i++) {\n const [x1, y1] = points[i];\n for (let j = i + 1; j < points.length; j++) {\n const [x2, y2] = points[j];\n if (x1 !== x2 && y1 !== y2) {\n if (pointSet.has(`${x1},${y2}`) && pointSet.has(`${x2},${y1}`)) {\n const area = Math.abs(x1 - x2) * Math.abs(y1 - y2);\n result = result === 0 ? area : Math.min(result, area);\n }\n }\n }\n }\n\n return result;\n};","keywords":"LeetCode 939, #939 - Minimum Area Rectangle, Medium, JavaScript solution","learningResourceType":"Code","isAccessibleForFree":true,"educationalLevel":"intermediate","interactivityType":"mixed"}
| author | LeetCodeJavascript.com |
| og:type | article |
| og:image | https://leetcodejavascript.com/og-image.jpg |
| og:site_name | LeetCode JavaScript Solutions |
| twitter:card | summary_large_image |
| twitter:url | https://leetcodejavascript.com/solutions/minimum-area-rectangle |
| twitter:image | https://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/minimum-area-rectangle/ |
| View on GitHub | https://github.com/JoshCrozier/leetcode-javascript/blob/master/solutions/0939-minimum-area-rectangle.js |
| Array | https://leetcodejavascript.com/tags/array |
| Hash Table | https://leetcodejavascript.com/tags/hash-table |
| Math | https://leetcodejavascript.com/tags/math |
| Sorting | https://leetcodejavascript.com/tags/sorting |
| Geometry | https://leetcodejavascript.com/tags/geometry |
| Josh Crozier | https://joshcrozier.com |
Viewport: width=device-width, initial-scale=1.0
Robots: index, follow