http://haixiaoyang.wordpress.com/2012/03/25/find-the-smallest-window-of-a-certain-sequence/
//Given an input array of integers of size n, and a query array of
//integers of size k, find the smallest window of input array that
//contains all the elements of query array and also in the same order
int GetMinOrder(int a[], int n, int b[], int m)
{
assert(a && n > 0 && b && m > 0 && n >= m);
int nMin = -1;
for (int i = 0; i < n; i++)
{
if (a[i] != b[0]) continue;
int nCur = 0;
int j = i;
for (; j < n && nCur < m; j++)
{
if (a[j] == b[nCur])
nCur++;
}
if (nCur == m)
nMin = nMin < 0 ? (j - i) : min(nMin, (j-i));
else break;
}
return nMin;
}