Title: #401 - Binary Watch - LeetCode JavaScript Solutions
Open Graph Title: #401 - Binary Watch - LeetCode JavaScript Solutions
X Title: #401 - Binary Watch - LeetCode JavaScript Solutions
Description: A binary watch has 4 LEDs on the top to represent the hours (0-11), and 6 LEDs on the bottom to represent the minutes (0-59). Each LED repre...
Open Graph Description: A binary watch has 4 LEDs on the top to represent the hours (0-11), and 6 LEDs on the bottom to represent the minutes (0-59). Each LED repre...
X Description: A binary watch has 4 LEDs on the top to represent the hours (0-11), and 6 LEDs on the bottom to represent the minutes (0-59). Each LED repre...
Keywords:
Opengraph URL: https://leetcodejavascript.com/solutions/binary-watch
Domain: leetcodejavascript.com
{"@context":"https://schema.org","@type":"Code","url":"https://leetcodejavascript.com/solutions/binary-watch","name":"#401 - Binary Watch - LeetCode JavaScript Solutions","description":"A binary watch has 4 LEDs on the top to represent the hours (0-11), and 6 LEDs on the bottom to represent the minutes (0-59). Each LED repre...","programmingLanguage":"JavaScript","codeRepository":"https://github.com/JoshCrozier/leetcode-javascript","codeSampleType":"JavaScript","text":"/**\n * @param {number} turnedOn\n * @return {string[]}\n */\nvar readBinaryWatch = function(turnedOn) {\n const result = [];\n\n for (let h = 0; h < 12; h++) {\n for (let m = 0; m < 60; m++) {\n if (h.toString(2).split('1').length - 1 + m.toString(2).split('1').length - 1 === turnedOn) {\n result.push(`${h}:${m < 10 ? '0' + m : m}`);\n }\n }\n }\n\n return result;\n};","keywords":"LeetCode 401, #401 - Binary Watch, 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/binary-watch |
| 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/binary-watch/ |
| View on GitHub | https://github.com/JoshCrozier/leetcode-javascript/blob/master/solutions/0401-binary-watch.js |
| Bit Manipulation | https://leetcodejavascript.com/tags/bit-manipulation |
| Backtracking | https://leetcodejavascript.com/tags/backtracking |
| Josh Crozier | https://joshcrozier.com |
Viewport: width=device-width, initial-scale=1.0
Robots: index, follow