Skip to content

Commit

Permalink
null if the sums of the two vec are not equal
Browse files Browse the repository at this point in the history
  • Loading branch information
europeanplaice committed Feb 18, 2022
1 parent acd7dea commit 7199cd3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subset_sum"
version = "0.8.3"
version = "0.8.4"
edition = "2018"
authors = ["Tomohiro Endo <europeanplaice@gmail.com>"]
description = "Solves subset sum problem and returns a set of decomposed integers. It also can match corresponding numbers from two vectors and be used for Account reconciliation."
Expand Down
8 changes: 8 additions & 0 deletions src/dp_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,10 @@ pub mod dp {
n_key: usize,
key_orig: &mut Vec<i32>,
) {
if key.iter().sum::<i32>() != targets.iter().sum() {
return;
}

if key.len() == 0 && targets.len() == 0 {
answer.push(group.clone());
return;
Expand Down Expand Up @@ -527,6 +531,10 @@ pub mod dp {
),
]
);

let answer = sequence_matcher_m2m(&mut vec![1, 2, 3, 4], &mut vec![1, 5], 10);

assert_eq!(answer.len(), 0);
}
}

Expand Down

0 comments on commit 7199cd3

Please sign in to comment.