Title: #1271 - Hexspeak - LeetCode JavaScript Solutions
Open Graph Title: #1271 - Hexspeak - LeetCode JavaScript Solutions
X Title: #1271 - Hexspeak - LeetCode JavaScript Solutions
Description: A decimal number can be converted to its Hexspeak representation by first converting it to an uppercase hexadecimal string, then replacing a...
Open Graph Description: A decimal number can be converted to its Hexspeak representation by first converting it to an uppercase hexadecimal string, then replacing a...
X Description: A decimal number can be converted to its Hexspeak representation by first converting it to an uppercase hexadecimal string, then replacing a...
Keywords:
Opengraph URL: https://leetcodejavascript.com/solutions/hexspeak
Domain: leetcodejavascript.com
{"@context":"https://schema.org","@type":"Code","url":"https://leetcodejavascript.com/solutions/hexspeak","name":"#1271 - Hexspeak - LeetCode JavaScript Solutions","description":"A decimal number can be converted to its Hexspeak representation by first converting it to an uppercase hexadecimal string, then replacing a...","programmingLanguage":"JavaScript","codeRepository":"https://github.com/JoshCrozier/leetcode-javascript","codeSampleType":"JavaScript","text":"/**\n * @param {string} num\n * @return {string}\n */\nvar toHexspeak = function(num) {\n const hex = BigInt(num).toString(16).toUpperCase();\n const validChars = new Set(['0', '1', 'A', 'B', 'C', 'D', 'E', 'F']);\n\n for (const char of hex) {\n if (!validChars.has(char)) {\n return 'ERROR';\n }\n }\n\n return hex.replace(/0/g, 'O').replace(/1/g, 'I');\n};","keywords":"LeetCode 1271, #1271 - Hexspeak, Easy, 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/hexspeak |
| 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/hexspeak/ |
| View on GitHub | https://github.com/JoshCrozier/leetcode-javascript/blob/master/solutions/1271-hexspeak.js |
| String | https://leetcodejavascript.com/tags/string |
| Math | https://leetcodejavascript.com/tags/math |
| Josh Crozier | https://joshcrozier.com |
Viewport: width=device-width,initial-scale=1
Robots: index, follow