← Evaluations/EVAL-20260402-122330
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
Grok 4.20
openrouter
9.49
WINNER SCORE
matrix avg: 8.87
↓ results.json↓ report.mdFull dataset (CSV) →
10×10 Judgment Matrix · 89 judgments
OPEN 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.4—9.23.68.69.68.46.58.85.77.8
Claude Opus 4.610.0—7.19.89.88.89.29.28.79.2
Gemini 3.1 Pro10.09.2—9.010.08.28.110.07.210.0
Claude Sonnet 4.69.49.27.3—9.28.39.08.69.09.0
Grok 4.208.88.47.99.0—6.88.87.88.78.6
DeepSeek V49.49.49.19.69.6—9.69.69.79.4
GPT-OSS-120B8.88.87.8·8.87.5—8.88.38.6
Gemini 310.09.89.810.010.09.89.6—9.410.0
MiniMax M2.59.88.88.310.09.38.88.68.4—8.8
MiMo-V2-Flash8.89.08.69.49.28.89.69.39.0—