고급
Algorithmic Complexity Refactoring
Refactor a provided inefficient code snippet to optimal time complexity while maintaining readability.
📝 Prompt Content
Review the following Python code snippet (placeholder: 'A nested loop O(n^2) function finding duplicate pairs in a list'). Refactor this code to achieve O(n) or O(n log n) time complexity. Provide the optimized code and a detailed explanation of the changes made. Additionally, discuss the space-time trade-offs of your new solution compared to the original and explain under what memory constraints the original algorithm might actually be preferred.