Workspace Linear Scan
0d
Problem-solving patterns

Linear Scan

Inspect each item once in input order.

Recognition signal

The data has no ordering that rules out a region.

Method

Maintain the answer for the prefix already visited.

Worked example

Finding 8 in [4, 1, 8] reads all three positions.

Common mistake

An early return is only valid if later values cannot change the answer.