Rust Stone Blocks
fn stone_blocks(h: &[i64]) -> i64 {
    let mut height: Vec<i64> = Vec::new();
    let mut blocks = 0i64;

    for &i in h {
        while let Some(&last) = height.last() {
            if last > i {
                height.pop();
            } else {
                break;
            }
        }
        if let Some(&last) = height.last() {
            if last == i {
                continue;
            }
        }

        height.push(i);
        blocks += 1;
    }

    blocks
}

This uses a stack of active heights and only counts a new block when the wall needs a new height segment.