Linear Scan

Iterate through an array once, tracking a running answer or stopping early when the target is found.

Iterate through an array once, tracking a running answer or stopping early when the target is found.

After processing index i, the running answer reflects the optimal result over elements 0…i.

Unsorted data gives no structural shortcut — every element must be examined at least once.

Carrying a running answer forward avoids re-scanning and keeps space constant.