static int no_of_chars = 256;
static String findSubString(String str,
Console.WriteLine("No such window exists");
int[] hash_pat = new int[no_of_chars];
int[] hash_str = new int[no_of_chars];
for (int i = 0; i < len2; i++)
int start = 0, start_index = -1,
for (int j = 0; j < len1; j++) {
if (hash_str[str[j]] <= hash_pat[str[j]])
while (hash_str[str[start]]
|| hash_pat[str[start]] == 0) {
int len_window = j - start + 1;
if (min_len > len_window) {
Console.WriteLine("No such window exists");
return str.Substring(start_index, min_len);
public static void Main(String[] args)
String str = "timetopractice";
Console.WriteLine(findSubString(str, pat));