Short answer
Time complexity measures how the number of operations grows with n; space complexity measures how much EXTRA memory the algorithm needs as a function of n (not counting the input itself).
Explanation
They can trade off: the duplicate-detection trick that uses a HashSet turns an O(n^2)-time, O(1)-space nested scan into an O(n)-time solution that costs O(n) extra space. Interviewers often ask you to state both.
Common mistakes
- Ignoring extra memory such as copies or recursion depth.
- Treating time and space complexity as the same thing.