substring matching

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…

Hi, Why don’t you post a link to the problem statement itself? That will help others better understand the problem. Your question, as of now, is quite unclear and vague.

Given a string S and and integer K, find the integer C which equals the number of pairs of substrings(S1,S2) such that S1 and S2 have equal length and Mismatch(S1, S2) <= K where the mismatch function.is number of diffrent char in string.
ex.
mismatch(abc,sbf)=2.(a and f are diffrent)…