A modified Naive Pattern Searching algorithm that is optimized for the cases when all characters of pattern are different
function search ( pat , txt ) { let M = pat . length ; let N = txt . length ; let i = 0 ; while ( i <= N - M ) { let j ;