we are given integer k and a string str

we have to find answer s which is equal to kmatch(s1,s2)<=k;

where s1 and s2 are substrings of equal length.

i have solve this questions using brute force algo for generating all subsets and match in o(n^2).

which gives me TLE.

plz help me solving this problem…

thanks…