using System.Collections.Generic;
public static void Main()
Console.WriteLine("Hello World");
Console.WriteLine(PermutationString("BACDGABCDAB","ABCD"));
PermuationString2("BACDGABCDAB","ABCD");
private static void PermuationString2(string a,string b)
int[] charP = new int[256];
int[] charT = new int[256];
for(int i=0;i<b.Length;i++)
for(int i=b.Length;i<a.Length;i++)
if ( CompareArray(charP,charT))
Console.WriteLine("start Index is " + (i-b.Length).ToString());
private static bool CompareArray(int[] a,int[] b)
private static int PermutationString(string a, string b)
if ( a.Length < b.Length )
int aLength = a.Length-1;
int bLength = b.Length-1;
Dictionary<char,int> hashB = new Dictionary<char,int>();
for(int i=0;i<b.Length;i++)
if ( hashB.ContainsKey(b[i]))
for(int i =0;i<a.Length-b.Length;i++)
string s = a.Substring(i,b.Length);
Dictionary<char,int> hashA = new Dictionary<char,int>();
for(int j=0;j<s.Length;j++)
if (!hashB.ContainsKey(s[j]))
if ( hashA.ContainsKey(s[j]))
foreach(var item in hashB)
int temp = hashA[item.Key];
if ( temp != item.Value )