mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-02 21:24:53 +08:00
Many bug fixes and improvements (#1270)
* Add Ruby and Kotlin icons Add the avatar of @curtishd * Update README * Synchronize zh-hant and zh versions. * Translate the pythontutor blocks to traditional Chinese * Fix en/mkdocs.yml * Update the landing page of the en version. * Fix the Dockerfile * Refine the en landingpage * Fix en landing page * Reset the README.md
This commit is contained in:
@ -25,7 +25,7 @@ impl TreeNode {
|
||||
height: 0,
|
||||
parent: None,
|
||||
left: None,
|
||||
right: None
|
||||
right: None,
|
||||
}))
|
||||
}
|
||||
}
|
||||
@ -34,7 +34,7 @@ impl TreeNode {
|
||||
macro_rules! op_vec {
|
||||
( $( $x:expr ),* ) => {
|
||||
vec![
|
||||
$( Option::from($x).map(|x| x) ),*
|
||||
$( Option::from($x).map(|x| x) ),*
|
||||
]
|
||||
};
|
||||
}
|
||||
@ -75,9 +75,10 @@ pub fn vec_to_tree(arr: Vec<Option<i32>>) -> Option<Rc<RefCell<TreeNode>>> {
|
||||
fn tree_to_vec_dfs(root: Option<Rc<RefCell<TreeNode>>>, i: usize, res: &mut Vec<Option<i32>>) {
|
||||
if root.is_none() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
let root = root.unwrap();
|
||||
while i >= res.len() {
|
||||
// i + 1 is the minimum valid size to access index i
|
||||
while res.len() < i + 1 {
|
||||
res.push(None);
|
||||
}
|
||||
res[i] = Some(root.borrow().val);
|
||||
|
||||
Reference in New Issue
Block a user