The principle is the following:
0) If the first array is longer than the second one, it's not a subarray.
1) If the second array begins with the first (like [a,b] and [a,b,c,d]), then it's a subarray.
2) Else: If the first array is a subarray of the tail of the second one (that means, the part after the first element), then it's a subarray.
Just to be sure: tail([a,b,c,d]) == [b,c,d]
(since I don't know how that's called in Java.)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…