mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
402 B
33 lines
402 B
5 years ago
|
## invert tree
|
||
|
|
||
|
### Instructions:
|
||
|
Write a function that takes tree and inverts(flips) and returns it.
|
||
|
```
|
||
|
type Node struct {
|
||
|
Val int
|
||
|
Left *Node
|
||
|
Right *Node
|
||
|
}
|
||
|
```
|
||
|
Example:
|
||
|
```
|
||
|
Input:
|
||
|
7
|
||
|
/ \
|
||
|
5 10
|
||
|
/ \ / \
|
||
|
3 6 9 13
|
||
|
|
||
|
Output:
|
||
|
7
|
||
|
/ \
|
||
|
10 5
|
||
|
/ \ / \
|
||
|
13 9 6 3
|
||
|
```
|
||
|
Expected function:
|
||
|
```
|
||
|
func InvertTree(root *Node) *Node {
|
||
|
}
|
||
|
```
|