Title: #6 - ZigZag Conversion - LeetCode JavaScript Solutions
Open Graph Title: #6 - ZigZag Conversion - LeetCode JavaScript Solutions
X Title: #6 - ZigZag Conversion - LeetCode JavaScript Solutions
Description: The string `"PAYPALISHIRING"` is written in a zigzag pattern on a given number of rows like this: (you may want to display this pa...
Open Graph Description: The string `"PAYPALISHIRING"` is written in a zigzag pattern on a given number of rows like this: (you may want to display this pa...
X Description: The string `"PAYPALISHIRING"` is written in a zigzag pattern on a given number of rows like this: (you may want to display this pa...
Keywords:
Opengraph URL: https://leetcodejavascript.com/solutions/zigzag-conversion
Domain: leetcodejavascript.com
{"@context":"https://schema.org","@type":"Code","url":"https://leetcodejavascript.com/solutions/zigzag-conversion","name":"#6 - ZigZag Conversion - LeetCode JavaScript Solutions","description":"The string `"PAYPALISHIRING"` is written in a zigzag pattern on a given number of rows like this: (you may want to display this pa...","programmingLanguage":"JavaScript","codeRepository":"https://github.com/JoshCrozier/leetcode-javascript","codeSampleType":"JavaScript","text":"/**\n * @param {string} s\n * @param {number} numRows\n * @return {string}\n */\nvar convert = function(s, numRows) {\n const order = [...new Array(numRows).keys()];\n order.push(...order.slice(1, -1).reverse());\n\n const rows = new Array(numRows).fill('');\n [...s].forEach((c, i) => (rows[order[i % order.length]] += c));\n\n return rows.join('');\n};","keywords":"LeetCode 6, #6 - ZigZag Conversion, 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/zigzag-conversion |
| 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/zigzag-conversion/ |
| View on GitHub | https://github.com/JoshCrozier/leetcode-javascript/blob/master/solutions/0006-zigzag-conversion.js |
| String | https://leetcodejavascript.com/tags/string |
| Josh Crozier | https://joshcrozier.com |
Viewport: width=device-width,initial-scale=1
Robots: index, follow