mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 00:43:04 +08:00
Update 0226.翻转二叉树.md
This commit is contained in:
@ -257,7 +257,7 @@ public:
|
||||
## 其他语言版本
|
||||
|
||||
|
||||
Java
|
||||
### Java
|
||||
```Java
|
||||
//DFS递归
|
||||
class Solution {
|
||||
@ -308,7 +308,7 @@ class Solution {
|
||||
}
|
||||
```
|
||||
|
||||
Python
|
||||
### Python
|
||||
|
||||
递归法:前序遍历:
|
||||
```python
|
||||
@ -360,7 +360,7 @@ class Solution:
|
||||
return root
|
||||
```
|
||||
|
||||
Go
|
||||
### Go
|
||||
|
||||
递归版本的前序遍历
|
||||
```Go
|
||||
@ -469,7 +469,7 @@ func invertTree(root *TreeNode) *TreeNode {
|
||||
}
|
||||
```
|
||||
|
||||
JavaScript
|
||||
### JavaScript
|
||||
|
||||
使用递归版本的前序遍历
|
||||
```javascript
|
||||
@ -550,7 +550,7 @@ var invertTree = function(root) {
|
||||
};
|
||||
```
|
||||
|
||||
TypeScript:
|
||||
### TypeScript:
|
||||
|
||||
递归法:
|
||||
|
||||
@ -677,7 +677,7 @@ function invertTree(root: TreeNode | null): TreeNode | null {
|
||||
};
|
||||
```
|
||||
|
||||
C
|
||||
### C
|
||||
|
||||
递归法
|
||||
```c
|
||||
@ -724,7 +724,7 @@ struct TreeNode* invertTree(struct TreeNode* root){
|
||||
}
|
||||
```
|
||||
|
||||
Swift:
|
||||
### Swift:
|
||||
```swift
|
||||
// 前序遍历-递归
|
||||
func invertTree(_ root: TreeNode?) -> TreeNode? {
|
||||
@ -762,7 +762,6 @@ func invertTree1(_ root: TreeNode?) -> TreeNode? {
|
||||
}
|
||||
```
|
||||
|
||||
Swift
|
||||
|
||||
深度优先递归。
|
||||
|
||||
@ -856,7 +855,7 @@ object Solution {
|
||||
}
|
||||
```
|
||||
|
||||
rust
|
||||
### rust
|
||||
|
||||
```rust
|
||||
impl Solution {
|
||||
|
Reference in New Issue
Block a user