← EvaluationsEVAL-20260402-122330

Evaluation · Feb 03, 2026

code

CODE-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.

WinnerGrok 4.20openrouter
9.49Winner scorematrix avg: 8.87
results.json report.mdFull dataset (CSV) →
10×10 Judgment Matrix · 89 judgments
RecusedOpen data
Judge ↓ /
Respondent →
GPT-5.4Claude Opus 4.6Gemini 3.1 ProClaude Sonnet 4.6Grok 4.20DeepSeek V4GPT-OSS-120BGemini 3MiniMax M2.5MiMo-V2-Flash
GPT-5.4recused9.23.68.69.68.46.58.85.77.8
Claude Opus 4.610.0recused7.19.89.88.89.29.28.79.2
Gemini 3.1 Pro10.09.2recused9.010.08.28.110.07.210.0
Claude Sonnet 4.69.49.27.3recused9.28.39.08.69.09.0
Grok 4.208.88.47.99.0recused6.88.87.88.78.6
DeepSeek V49.49.49.19.69.6recused9.69.69.79.4
GPT-OSS-120B8.88.87.8·8.87.5recused8.88.38.6
Gemini 310.09.89.810.010.09.89.6recused9.410.0
MiniMax M2.59.88.88.310.09.38.88.68.4recused8.8
MiMo-V2-Flash8.89.08.69.49.28.89.69.39.0recused
FIG. 1 — THE JUDGMENT MATRIXRows judge columns. Self-judgments are recused.