Skip to content

Commit feb4cd6

Browse files
committed
1
1 parent fef4734 commit feb4cd6

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

notes/src/day14/lc144.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
```

notes/src/day9/lc459.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ abcdabcd
7474

7575

7676
```rust
77+
struct Solution {}
78+
7779
impl Solution {
7880
pub fn repeated_substring_pattern(s: String) -> bool {
7981
let s: Vec<u8> = s.bytes().collect();

0 commit comments

Comments
 (0)