mirror of
https://github.com/krahets/hello-algo.git
synced 2026-04-14 02:10:37 +08:00
Bug fixes and improvements (#1572)
* Sync zh and zh-hant versions. * Remove the polyfill.io link from mkdocs.yml * Update contributors' info for code reviewers and en/zh-hant versions reviewers. * Fix graph.md * Update avatars for English version reviewers. * Sync zh and zh-hant versions. * Fix two_sum_brute_force.png * Sync zh and zh-hant versions. Optimize structrue of index.html. * Format index.html
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
* Author: night-cruise (2586447362@qq.com)
|
||||
*/
|
||||
|
||||
include!("../include/include.rs");
|
||||
use hello_algo_rust::include::{print_util, tree_node};
|
||||
|
||||
/* 陣列表示下的二元樹類別 */
|
||||
struct ArrayBinaryTree {
|
||||
@@ -49,18 +49,11 @@ impl ArrayBinaryTree {
|
||||
|
||||
/* 層序走訪 */
|
||||
fn level_order(&self) -> Vec<i32> {
|
||||
let mut res = vec![];
|
||||
// 直接走訪陣列
|
||||
for i in 0..self.size() {
|
||||
if let Some(val) = self.val(i) {
|
||||
res.push(val)
|
||||
}
|
||||
}
|
||||
res
|
||||
self.tree.iter().filter_map(|&x| x).collect()
|
||||
}
|
||||
|
||||
/* 深度優先走訪 */
|
||||
fn dfs(&self, i: i32, order: &str, res: &mut Vec<i32>) {
|
||||
fn dfs(&self, i: i32, order: &'static str, res: &mut Vec<i32>) {
|
||||
if self.val(i).is_none() {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user