← Evaluations/EVAL-20260207-140934
code
Feb 03, 2026CODE-004

This function works but is O(n³). Optimize it to O(n log n) or better while maintaining correctness. ```python def find_triplets_with_sum(arr, target_sum): """Find all unique triplets in arr that sum to target_sum""" n = len(arr) result = [] for i in range(n): for j in range(i + 1, n): for k in range(j + 1, n): if arr[i] + arr[j] + arr[k] == target_sum: triplet = sorted([arr[i], arr[j], arr[k]]) if triplet not in result: result.append(triplet) return result ``` Explain your optimization approach and prove the new time complexity.

Winner
Claude Opus 4.5
Anthropic
9.64
WINNER SCORE
matrix avg: 8.57
results.json report.mdFull dataset (CSV) →
10×10 Judgment Matrix · 100 judgments
OPEN DATA
Judge ↓ / Respondent →Claude Sonnet 4.5Grok Code FastClaude Opus 4.5Gemini 3Gemini 3MiniMax M2GLM-4-7DeepSeek V3.2GPT-5.2-CodexGrok 3 (Direct)
Claude Sonnet 4.58.89.87.09.60.00.09.88.39.2
Grok Code Fast9.69.88.39.82.02.09.89.89.8
Claude Opus 4.59.39.37.79.60.00.09.69.49.3
Gemini 30.00.00.00.00.00.00.00.00.0
Gemini 39.89.810.08.40.00.09.89.89.8
MiniMax M29.89.89.85.58.68.69.69.19.8
GLM-4-70.09.69.80.09.60.09.89.89.6
DeepSeek V3.29.69.010.07.99.69.89.69.19.6
GPT-5.2-Codex8.87.88.83.68.80.00.08.88.8
Grok 3 (Direct)9.68.69.27.09.07.07.08.88.6