pub fn min_depth_bfs<T>(root: &OptBinaryNode<T>) -> i32 {
    let mut depth: i32 = 0;
    if root.is_none() { return depth; }
    let mut queue: Vec<OptBinaryNode<T>> = Vec::new();
    queue.push(root.clone());
    while !queue.is_empty() {
        depth += 1;
        for _ in 0..queue.len() {
            let node = queue.remove(0);
            let node = RefCell::borrow(node.as_ref().unwrap());
            if node.left.is_none() && node.right.is_none() {
                return depth;
            }
            if node.left.is_some() {
                queue.push(node.left.clone());
            }
            if node.right.is_some() {
                queue.push(node.right.clone());
            }
        }
    }
    return depth;
}
// min_depth_bfs calculate the number of nodes on the shortest path from the root node to the nearest leaf node.
min_depth_bfs calculate the number of nodes on the shortest path from the root node to the nearest leaf node.
min_depth_bfs calculate the number of nodes on the shortest path from the root node to the nearest leaf node .
pub fn min_depth_bfs<T>(root: &OptBinaryNode<T>) -> i32 {
    let mut depth: i32 = 0;
    if root.is_none() { return depth; }
    let mut queue: Vec<OptBinaryNode<T>> = Vec::new();
    queue.push(root.clone());
    while !queue.is_empty() {
        depth += 1;
        for _ in 0..queue.len() {
            let node = queue.remove(0);
            let node = RefCell::borrow(node.as_ref().unwrap());
            if node.left.is_none() && node.right.is_none() {
                return depth;
            }
            if node.left.is_some() {
                queue.push(node.left.clone());
            }
            if node.right.is_some() {
                queue.push(node.right.clone());
            }
        }
    }
    return depth;
}
pub fn min_depth_bfs < T > ( root : & OptBinaryNode < T > ) -> i32 { let mut depth : i32 = 0 ; if root . is_none ( ) { return depth ; } let mut queue : Vec < OptBinaryNode < T > > = Vec :: new ( ) ; queue . push ( root . clone ( ) ) ; while ! queue . is_empty ( ) { depth += 1 ; for _ in 0 .. queue . len ( ) { let node = queue . remove ( 0 ) ; let node = RefCell :: borrow ( node . as_ref ( ) . unwrap ( ) ) ; if node . left . is_none ( ) && node . right . is_none ( ) { return depth ; } if node . left . is_some ( ) { queue . push ( node . left . clone ( ) ) ; } if node . right . is_some ( ) { queue . push ( node . right . clone ( ) ) ; } } } return depth ; }
min_depth_bfs calculate the number of nodes on the shortest path from the root node to the nearest leaf node.
min_depth_bfs calculate the number of nodes on the shortest path from the root node to the nearest leaf node .
root
&OptBinaryNode<T>