advanced
Algorithm Complexity Analysis
Optimize a pseudo-code snippet for better time and space complexity.
📝 Promptens innehåll
Analyze the following pseudo-code function which finds the sum of all unique pairs in an array. Identify the time and space complexity, explain the bottlenecks, and rewrite the function to achieve O(n) time complexity or better, explaining the trade-offs involved in your new approach.