closest-sum-pair 0.1.1

Finds a pair in a list that has the closest sum to a given number.
Documentation
closest-sum-pair-0.1.1 has been yanked.

closest_sum_pair

Finds a pair from a vector of type i32, that has the closest sum to a given number. If there are multiple choices, pair that has most distance between them is selected.

The algorithm has time complexity of O(NlogN) and space complexity of O(1).

Quick Start

use closest_sum_pair::Elements;

let mut list: Vec<i32> = vec![3 ,5, 7];

let len: usize = list.len();

let desired_sum: i32 = 9;

let elements = Elements::new(&mut list, len, desired_sum);

elements.sort_list().find_init_distance().find_pair().result();