fn day_1_find_two_numbers_summing_to(nums: &[i32], sum_target: i32) -> Option<i32> {
    let mut b_idx = nums.len() - 1;
    for a in nums.iter() {
        let expected_b = sum_target - a;

        let mut b = nums[b_idx];
        while b >= expected_b {
            if b == expected_b {
                return Some(a * b);
            }

            if b_idx == 0 {
                return None;
            }

            b_idx -= 1;
            b = nums[b_idx];
        }
    }

    None
}
/// Algorithm here will look one number at a time, subtract it from
/// `sum_target`, and then look at each number starting from the end of the
/// array to see if there is a number equal to this.
///
/// Each loop is made faster by continuing the search for the bigger number
/// from the index we looked at last in the previous iteration (since we
/// know it's the number from which all numbers after it must be too big).
///
/// Note: `nums` must be sorted when passed to this algorithm.
Algorithm here will look one number at a time, subtract it from
`sum_target`, and then look at each number starting from the end of the
array to see if there is a number equal to this.

Each loop is made faster by continuing the search for the bigger number
from the index we looked at last in the previous iteration (since we
know it's the number from which all numbers after it must be too big).

`nums` must be sorted when passed to this algorithm.
Algorithm here will look one number at a time subtract it from ` sum_target ` and then look at each number starting from the end of the array to see if there is a number equal to this . Each loop is made faster by continuing the search for the bigger number from the index we looked at last in the previous iteration ( since we know it ' s the number from which all numbers after it must be too big ) . ` nums ` must be sorted when passed to this algorithm .
fn day_1_find_two_numbers_summing_to(nums: &[i32], sum_target: i32) -> Option<i32> {
    let mut b_idx = nums.len() - 1;
    for a in nums.iter() {
        let expected_b = sum_target - a;
        let mut b = nums[b_idx];
        while b >= expected_b {
            if b == expected_b {
                return Some(a * b);
            }
            if b_idx == 0 {
                return None;
            }
            b_idx -= 1;
            b = nums[b_idx];
        }
    }
    None
}
fn day_1_find_two_numbers_summing_to ( nums : & [ i32 ] , sum_target : i32 ) -> Option < i32 > { let mut b_idx = nums . len ( ) - 1 ; for a in nums . iter ( ) { let expected_b = sum_target - a ; let mut b = nums [ b_idx ] ; while b >= expected_b { if b == expected_b { return Some ( a * b ) ; } if b_idx == 0 { return None ; } b_idx -= 1 ; b = nums [ b_idx ] ; } } None }
Algorithm here will look one number at a time, subtract it from
`sum_target`, and then look at each number starting from the end of the
array to see if there is a number equal to this.
Algorithm here will look one number at a time subtract it from ` sum_target ` and then look at each number starting from the end of the array to see if there is a number equal to this .
nums
&[i32]
sum_target
i32