Two sum from leetcode

In a second example this part:

is adding you one extra loop over whole nums list. You can pass i as a fourth argument to helper/3 function and work with it similarly to how you do that in an Enum.reduce_while/3-based example.