LeetCode: Check If A String Contains All Binary Codes Of Size K Solution
1/**2 * @param {string} s3 * @param {number} k4 * @return {boolean}5 */6var hasAllCodes = function (s, k) {7 return (8 new Set(9 Array.from({ length: s.length - k + 1 }, (_, i) => s.substring(i, i + k))10 ).size === Math.pow(2, k)11 )12}
Comments
Loading comments...
Tags
leetcode
string
bit manipulation
Apply and earn a $2,500 bonus once you're hired on your first job!
Clients from the Fortune 500 to Silicon Valley startups
Choose your own rate, get paid on time
From hourly, part-time, to full-time positions
Flexible remote working environment
A lot of open JavaScript jobs!!
Fact corner: Referred talent are 5x more likely to pass the Toptal screening process than the average applicant.
Still hesitate? Read HoningJS author's guide on dealing with Toptal interview process.