Function largest_rectangle

Source
pub fn largest_rectangle(hist: &[usize]) -> usize
Examples found in repository?
crates/aizu_online_judge/src/dpl/dpl_3_c.rs (line 10)
6pub fn dpl_3_c(reader: impl Read, mut writer: impl Write) {
7    let s = read_all_unchecked(reader);
8    let mut scanner = Scanner::new(&s);
9    scan!(scanner, n, h: [usize; n]);
10    writeln!(writer, "{}", largest_rectangle(&h)).ok();
11}
More examples
Hide additional examples
crates/competitive/src/combinatorial_optimization/largest_pattern.rs (line 44)
37pub fn largest_rectangle_in_grid(h: usize, w: usize, ok: impl Fn(usize, usize) -> bool) -> usize {
38    let mut hist = vec![0; w];
39    let mut res = 0;
40    for i in 0..h {
41        for (j, hist) in hist.iter_mut().enumerate() {
42            *hist = if ok(i, j) { *hist + 1 } else { 0 };
43        }
44        res = res.max(largest_rectangle(&hist));
45    }
46    res
47}