forked from Xunzhuo/Algorithm-Guide
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path25.java
More file actions
54 lines (30 loc) · 602 Bytes
/
Copy path25.java
File metadata and controls
54 lines (30 loc) · 602 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
class Solution {
public TreeNode mirrorTree(TreeNode root) {
if(root==null)
{
return root;
}
if(root.left==null&&root.right==null)
{
return root;
}
find(root);
return root;
}
public void find(TreeNode p)
{
if(p==null)
{
return;
}
if(p.left==null&&p.right==null)
{
return;
}
TreeNode t = p.left;
p.left = p.right;
p.right = t;
find(p.left);
find(p.right);
}
}