Repair a LeetCode-style or coding-interview attempt with the fewest line and token changes needed for correctness, preserving the attempted approach. Use when explicitly invoked on attached, pictured, or pasted code.