File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -69,3 +69,25 @@ public:
6969```
7070
7171## 学习感想
72+
73+ 为什么当时没有用rust做呢
74+
75+ ```js
76+ use std::rc::Rc;
77+ use std::cell::RefCell;
78+ impl Solution {
79+ pub fn preorder_traversal(root: Option<Rc<RefCell<TreeNode>>>) -> Vec<i32> {
80+ if let Some(r) = root {
81+ // use std::ops::DerefMut;
82+ // let mut ref_node: std::cell::RefMut<TreeNode> = r.borrow_mut();
83+ // let node: &mut TreeNode = &mut ref_node;
84+ let mut res: Vec<i32> = vec![r.borrow().val];
85+ res.append(&mut Self::preorder_traversal(r.borrow_mut().left.take()));
86+ res.append(&mut Self::preorder_traversal(r.borrow_mut().right.take()));
87+ res
88+ } else {
89+ vec![]
90+ }
91+ }
92+ }
93+ ```
Original file line number Diff line number Diff line change @@ -74,6 +74,8 @@ abcdabcd
7474
7575
7676``` rust
77+ struct Solution {}
78+
7779impl Solution {
7880 pub fn repeated_substring_pattern (s : String ) -> bool {
7981 let s : Vec <u8 > = s . bytes (). collect ();
You can’t perform that action at this time.
0 commit comments