Check if a binary string contains all permutations of length k | Javascript program to Check If a String Contains All Binary Codes of Size K ; Unordered map of type string ; Driver code
function hasAllcodes ( s , k ) { let us = new Set ( ) ; for ( let i = 0 ; i + k <= s . length ; i ++ ) { us . add ( s . substring ( i , i + k ) ) ; } return ( us . size == ( 1 << k ) ) ; } let s = " " ; let k = 2 ; if ( hasAllcodes ( s , k ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; }