Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4308b3c

Browse filesBrowse files
committed
Trees
1 parent 05bb9fe commit 4308b3c
Copy full SHA for 4308b3c

File tree

1 file changed

+10
-0
lines changed
Filter options

1 file changed

+10
-0
lines changed

‎src/leetcode2018/Trees.java

Copy file name to clipboardExpand all lines: src/leetcode2018/Trees.java
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,18 @@ public boolean isSameTree(TreeNode p, TreeNode q) {
100100
if(p==null && q==null) return true;
101101
if(p==null || q==null) return false;
102102
if(p.val!=q.val) return false;
103+
System.out.println("p:"+p.val+ " , q"+q.val);
103104
return isSameTree(p.left, q.left) && isSameTree(p.right, q.right);
104105
}
106+
107+
public TreeNode invertTree(TreeNode root) {
108+
if(root==null) return null;
109+
TreeNode temp= root.left;
110+
root.left= invertTree(root.right);
111+
root.right= invertTree(temp);
112+
System.out.println("mid:"+root.val);
113+
return root;
114+
}
105115

106116
}
107117

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.