Title: #356 - Line Reflection - LeetCode JavaScript Solutions
Open Graph Title: #356 - Line Reflection - LeetCode JavaScript Solutions
X Title: #356 - Line Reflection - LeetCode JavaScript Solutions
Description: Given n points on a 2D plane, find if there is such a line parallel to the y-axis that reflects the given points symmetrically. In other wor...
Open Graph Description: Given n points on a 2D plane, find if there is such a line parallel to the y-axis that reflects the given points symmetrically. In other wor...
X Description: Given n points on a 2D plane, find if there is such a line parallel to the y-axis that reflects the given points symmetrically. In other wor...
Keywords:
Opengraph URL: https://leetcodejavascript.com/solutions/line-reflection
Domain: leetcodejavascript.com
{"@context":"https://schema.org","@type":"Code","url":"https://leetcodejavascript.com/solutions/line-reflection","name":"#356 - Line Reflection - LeetCode JavaScript Solutions","description":"Given n points on a 2D plane, find if there is such a line parallel to the y-axis that reflects the given points symmetrically. In other wor...","programmingLanguage":"JavaScript","codeRepository":"https://github.com/JoshCrozier/leetcode-javascript","codeSampleType":"JavaScript","text":"/**\n * @param {number[][]} points\n * @return {boolean}\n */\nvar isReflected = function(points) {\n const pointSet = new Set(points.map(([x, y]) => `${x},${y}`));\n let minX = Infinity;\n let maxX = -Infinity;\n\n for (const [x] of points) {\n minX = Math.min(minX, x);\n maxX = Math.max(maxX, x);\n }\n\n const sum = minX + maxX;\n for (const [x, y] of points) {\n if (!pointSet.has(`${sum - x},${y}`)) {\n return false;\n }\n }\n\n return true;\n};","keywords":"LeetCode 356, #356 - Line Reflection, 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/line-reflection |
| 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/line-reflection/ |
| View on GitHub | https://github.com/JoshCrozier/leetcode-javascript/blob/master/solutions/0356-line-reflection.js |
| Array | https://leetcodejavascript.com/tags/array |
| Hash Table | https://leetcodejavascript.com/tags/hash-table |
| Math | https://leetcodejavascript.com/tags/math |
| Josh Crozier | https://joshcrozier.com |
Viewport: width=device-width,initial-scale=1
Robots: index, follow