Whenever you're ready, walk me through how you'd approach this.
How would you optimize a given algorithm for better performance?
Discuss how you would identify bottlenecks, analyze time and space complexity, select improved algorithms or data structures, and validate that optimizations preserve correctness. Address practical concerns such as memory usage, cache behavior, input characteristics, and measurement methodology.