We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 43248da commit 0f8e5bdCopy full SHA for 0f8e5bd
src/monotonic/count_rects.rs
@@ -43,10 +43,10 @@ pub fn count_rects(grid: &[Vec<bool>]) -> Vec<Vec<i32>> {
43
let le = mono_st(&h, |x, y| x.lt(y));
44
let ri = mono_range(&le);
45
for j in 0..m {
46
- let (cnt_l, cnt_r) = (j - le[j].wrapping_add(1), ri[j] - j - 1);
47
- cnt[h[j]][cnt_l + cnt_r + 1] += 1;
48
- cnt[h[j]][cnt_l] -= 1;
49
- cnt[h[j]][cnt_r] -= 1;
+ let (cnt_l, cnt_r) = (j.wrapping_sub(le[j]), ri[j] - j);
+ cnt[h[j]][cnt_l + cnt_r - 1] += 1;
+ cnt[h[j]][cnt_l - 1] -= 1;
+ cnt[h[j]][cnt_r - 1] -= 1;
50
}
51
52
for row in cnt.iter_mut().skip(1) {
0 commit comments