Improve the time, space, constant factors, and interview cleanliness of a LeetCode-style or coding-interview solution while retaining its recognizable algorithmic idea. Use when explicitly invoked on attached, pictured, or pasted code.