Title: #475 - Heaters - LeetCode JavaScript Solutions
Open Graph Title: #475 - Heaters - LeetCode JavaScript Solutions
X Title: #475 - Heaters - LeetCode JavaScript Solutions
Description: Winter is coming! During the contest, your first job is to design a standard heater with a fixed warm radius to warm all the houses. Every h...
Open Graph Description: Winter is coming! During the contest, your first job is to design a standard heater with a fixed warm radius to warm all the houses. Every h...
X Description: Winter is coming! During the contest, your first job is to design a standard heater with a fixed warm radius to warm all the houses. Every h...
Keywords:
Opengraph URL: https://leetcodejavascript.com/solutions/heaters
Domain: leetcodejavascript.com
{"@context":"https://schema.org","@type":"Code","url":"https://leetcodejavascript.com/solutions/heaters","name":"#475 - Heaters - LeetCode JavaScript Solutions","description":"Winter is coming! During the contest, your first job is to design a standard heater with a fixed warm radius to warm all the houses. Every h...","programmingLanguage":"JavaScript","codeRepository":"https://github.com/JoshCrozier/leetcode-javascript","codeSampleType":"JavaScript","text":"/**\n * @param {number[]} houses\n * @param {number[]} heaters\n * @return {number}\n */\nvar findRadius = function(houses, heaters) {\n let result = 0;\n\n houses.sort((a, b) => a - b);\n heaters.sort((a, b) => a - b);\n for (let i = 0, j = 0; i < houses.length; i++) {\n while (j < heaters.length - 1 && houses[i] - heaters[j] > heaters[j + 1] - houses[i]) {\n j++;\n }\n result = Math.max(result, Math.abs(heaters[j] - houses[i]));\n }\n\n return result;\n};","keywords":"LeetCode 475, #475 - Heaters, 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/heaters |
| 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/heaters/ |
| View on GitHub | https://github.com/JoshCrozier/leetcode-javascript/blob/master/solutions/0475-heaters.js |
| Array | https://leetcodejavascript.com/tags/array |
| Sorting | https://leetcodejavascript.com/tags/sorting |
| Binary Search | https://leetcodejavascript.com/tags/binary-search |
| Two Pointers | https://leetcodejavascript.com/tags/two-pointers |
| Josh Crozier | https://joshcrozier.com |
Viewport: width=device-width, initial-scale=1.0
Robots: index, follow