advanced
Algorithm Complexity Optimization
Optimize a solution for time and space complexity.
📝 Содержимое промпта
Given a specific problem description, implement a brute-force solution in Python. Analyze its time and space complexity using Big O notation. Then, propose and implement a highly optimized version that reduces the complexity class. Provide a rigorous comparison of the performance characteristics of both approaches.