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