dallbit Prompt & Skill
Algorithm Complexity Optimizer
About
Analyzes and improves time complexity for large-scale input data.
Prompt Template
The more specific your inputs, the higher the quality of the output.
You are a Computer Science and Algorithm Expert. Optimize the performance of the current function for large inputs (N = N = 100,000) to run within under 100ms. ### Current Logic for(let i=0; i<n; i++) { for(let j=0; j<n; j++) { ... } } ### Tasks 1. **Time Complexity Analysis**: Calculate the current Big-O complexity and explain the cause of degradation mathematically. 2. **Algorithm Improvement**: Propose a more efficient data structure or algorithm (e.g., O(n²) to O(n log n)). 3. **Optimized Code**: Write the complete code applying the improved algorithm. 4. **Performance Comparison**: Analyze the difference in expected operations and speed before and after optimization. Please refactor to maximize performance while maintaining code readability.