# Answer It in One Step: Trading Memory for Time

Answer "how long are the first few songs?" in one step instead of a loop, by spending a little memory on running totals, and measure both sides of that trade in Big-O: time complexity and space complexity.

![Cheat sheet: Answer It in One Step: Trading Memory for Time](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/2d214fd6ddb446a3a8070d674cc9da0f.webp)

- Category: Data Structures
- Level: Apprentice
- Tags: software-development, Space Complexity, Time Complexity, Trade-Off
- Updated: November 3, 2026

Source: https://www.ask-codey.com/cheat-sheets/big-o-time-vs-memory-cheat-sheet
