Use the prompt
Include representative input sizes and the result the algorithm must preserve. Measure the proposed implementation against the current one rather than relying on a complexity claim alone.
Improve algorithmic efficiency while maintaining correctness. Optimize hot paths for performance gains.
For GitLab Duo
Optimize this algorithm:
[PASTE CODE]
Goals:
1. Improve time complexity
2. Reduce memory usage
3. Maintain correctness
4. Keep code readableInclude representative input sizes and the result the algorithm must preserve. Measure the proposed implementation against the current one rather than relying on a complexity claim alone.