Skip to content

Commit

Permalink
58: Re-submit
Browse files Browse the repository at this point in the history
  • Loading branch information
sankichi92 committed Dec 29, 2023
1 parent 395297c commit c622c18
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion 58-combination-sum-iii/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub fn combination_sum3(k: i32, n: i32) -> Vec<Vec<i32>> {
}

for i in (0..k).rev() {
if candidate[i as usize] < 9 + k - 1 - i {
if candidate[i as usize] < 9 + i - (k - 1) {
candidate[i as usize] += 1;
for j in i + 1..k {
candidate[j as usize] = candidate[i as usize] + j - i;
Expand Down Expand Up @@ -61,4 +61,9 @@ mod tests {
]
);
}

#[test]
fn failed_case2() {
assert_eq!(combination_sum3(3, 28), Vec::<Vec<i32>>::new());
}
}

0 comments on commit c622c18

Please sign in to comment.