Trigger: “Sorted Array” + Finding a “Sum” + Space constraint. Mechanical Approach: Opposite-Directional Two Pointers.
leftat start (0),rightat end ().- If
sum < target: we need a bigger numberleft += 1. - If
sum > target: we need a smaller numberright -= 1. - If
sum == target: Return indices.
System/Engineering Value: - Replaces HashMap memory with pointer memory. Crucial for massive, sorted datasets that cannot fit into RAM (e.g., streaming large log files from disk where we only hold pointer offsets).
Blindspot: - The problem explicitly asks for 1-based indices. Return [left + 1, right + 1].