mirror of
https://github.com/krahets/hello-algo.git
synced 2026-05-12 03:27:44 +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:
@@ -14,7 +14,7 @@ use tree_node::{vec_to_tree, TreeNode};
|
||||
fn level_order(root: &Rc<RefCell<TreeNode>>) -> Vec<i32> {
|
||||
// 初始化佇列,加入根節點
|
||||
let mut que = VecDeque::new();
|
||||
que.push_back(Rc::clone(&root));
|
||||
que.push_back(root.clone());
|
||||
// 初始化一個串列,用於儲存走訪序列
|
||||
let mut vec = Vec::new();
|
||||
|
||||
@@ -22,10 +22,10 @@ fn level_order(root: &Rc<RefCell<TreeNode>>) -> Vec<i32> {
|
||||
// 隊列出隊
|
||||
vec.push(node.borrow().val); // 儲存節點值
|
||||
if let Some(left) = node.borrow().left.as_ref() {
|
||||
que.push_back(Rc::clone(left)); // 左子節點入列
|
||||
que.push_back(left.clone()); // 左子節點入列
|
||||
}
|
||||
if let Some(right) = node.borrow().right.as_ref() {
|
||||
que.push_back(Rc::clone(right)); // 右子節點入列
|
||||
que.push_back(right.clone()); // 右子節點入列
|
||||
};
|
||||
}
|
||||
vec
|
||||
|
||||
Reference in New Issue
Block a user