Skip to content

Commit

Permalink
remove some superfluous checks
Browse files Browse the repository at this point in the history
Signed-off-by: Lance-Drane <[email protected]>
Lance-Drane committed Jan 23, 2025
1 parent aefef7e commit fdb1482
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions src/bin/search_array_division.rs
Original file line number Diff line number Diff line change
@@ -665,25 +665,17 @@ fn solve<W: std::io::Write>(scan: &[u8], out: &mut W) {
}

fn sum_possible(arr: &[u64], k: u32, target: u64) -> bool {
let mut subarray_count = 0;
let mut subarray_count = 1;
let mut curr_sum = 0;

for num in arr {
if *num > target {
return false;
}

curr_sum += *num;
if curr_sum > target {
subarray_count += 1;
curr_sum = *num;
}
}

if curr_sum > 0 {
subarray_count += 1;
}

subarray_count <= k
}

0 comments on commit fdb1482

Please sign in to comment.