sub two_sum # O(n) { my ($i, $input, $target, %h) = (0, @_); return [ $h{$_} // ($h{$target - $_} = $i++, next), $i ] for @$input; }