This problem demonstrates the "linear scan with memory" pattern. Traverse a list while tracking information.
The same pattern applies to finding:
- Minimum value
- Second largest
- First negative
- Last even number
Key insight: you don't need to store all values. Track only what matters for your answer.
Time complexity is . You must check every element once. There's no way to find the maximum faster since any unchecked element could be the largest.
Space complexity is . You only store one variable (max_val) regardless of list size. This constant space usage makes the algorithm memory-efficient.