Discuss a scenario where you optimized an algorithm for efficiency. What considerations did you make in terms of time and space?