Update 0226.翻转二叉树.md

This commit is contained in:
程序员Carl
2022-11-30 11:58:41 +08:00
committed by GitHub
parent c24cc5573f
commit 1e873a1984

View File

@ -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 {