File tree 2 files changed +24
-0
lines changed
2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -69,3 +69,25 @@ public:
69
69
```
70
70
71
71
## 学习感想
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
74
74
75
75
76
76
``` rust
77
+ struct Solution {}
78
+
77
79
impl Solution {
78
80
pub fn repeated_substring_pattern (s : String ) -> bool {
79
81
let s : Vec <u8 > = s . bytes (). collect ();
You can’t perform that action at this time.
0 commit comments