Loop invariant

Setup a wall, on the left side of the wall are the elements which do not contain the target. When a new element comes and it does not equal to the target, enlarge the space on the left side of the wall, and move the new element into the left side of the wall.