param { string } s1 param { string } s2 return { boolean } function CheckInclusion ( s1 , s2 ) { if ( typeof s1 !== 'string' || typeof s2 !== 'string' || s1 . length === 0 || s2 . length === 0 ) { return false ; } let dictionary = new Array ( 26 ) . fill ( 0 ) ; for ( let i = 0 ; i < s1 . length ; i ++ ) { let code = s1 . charCodeAt ( i ) - 97 ; dictionary [ code ] ++ ; } for ( let start = 0 , end = 0 ; end < s2 . length ; end ++ ) { let code = s2 . charCodeAt ( end ) - 97 ; dictionary [ code ] -- ; while ( dictionary [ code ] < 0 ) { dictionary [ s2 . charCodeAt ( start ) - 97 ] ++ ; start ++ ; } if ( end - start + 1 === s1 . length ) return true ; } return false ; } export { CheckInclusion } ;