pub fn find_subset(
arr: Vec<i32>,
value: i32,
max_length: usize,
) -> Vec<Vec<i32>>Expand description
Finds subsets sum of a target value. It can accept negative values.
§Arguments
arr- An array.value- The value to the sum of the subset comes.max_length- The maximum length of combinations of the answer.
§Example
use dpss::dp::find_subset;
let arr = vec![-1, -3, -2, 6, 12, 48];
let result = find_subset(arr, 0, 4);
let route1: Vec<i32> = vec![-3, -2, -1, 6];
let answer: Vec<Vec<i32>> = vec![route1];
assert_eq!(result, answer);§Return Value
use dpss::dp::find_subset;
let result = find_subset(vec![1, 2, 3, -4, 5], 1, 2);
println!("{:?}", result);output: [[1], [-3, 4]]