Algorithm to determine indices i..j of array A containing all the elements of another array B
- by Skylark
I came across this question on an interview questions thread. Here is the question:
Given two integer arrays A [1..n] and
B[1..m], find the smallest window
in A that contains all elements of
B. In other words, find a pair < i , j
such that A[i..j] contains B[1..m].
If A doesn't contain all the elements of
B, then i,j can be…