Skip to content

Commit 1325a93

Browse files
refactor 617
1 parent 066e5a4 commit 1325a93

File tree

2 files changed

+0
-36
lines changed

2 files changed

+0
-36
lines changed

src/main/java/com/fishercoder/solutions/_617.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,6 @@
3232
public class _617 {
3333

3434
public static class Solution1 {
35-
public TreeNode mergeTrees(TreeNode t1, TreeNode t2) {
36-
if (t1 == null) {
37-
return t2;
38-
}
39-
if (t2 == null) {
40-
return t1;
41-
}
42-
TreeNode mergedNode = null;
43-
if (t1 != null && t2 != null) {
44-
mergedNode = new TreeNode(t1.val + t2.val);
45-
} else if (t1 != null) {
46-
mergedNode = t1;
47-
} else if (t2 != null) {
48-
mergedNode = t2;
49-
}
50-
mergedNode.left = mergeTrees(t1.left, t2.left);
51-
mergedNode.right = mergeTrees(t1.right, t2.right);
52-
return mergedNode;
53-
}
54-
}
55-
56-
public static class Solution2 {
5735
public TreeNode mergeTrees(TreeNode t1, TreeNode t2) {
5836
if (t1 == null) {
5937
return t2;

src/test/java/com/fishercoder/_617Test.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
public class _617Test {
1717
private static _617.Solution1 solution1;
18-
private static _617.Solution2 solution2;
1918
private static TreeNode t1;
2019
private static TreeNode t2;
2120
private static TreeNode actual;
@@ -24,7 +23,6 @@ public class _617Test {
2423
@BeforeClass
2524
public static void setup() {
2625
solution1 = new _617.Solution1();
27-
solution2 = new _617.Solution2();
2826
}
2927

3028
@Test
@@ -40,16 +38,4 @@ public void test1() {
4038
assertEquals(expected, actual);
4139
}
4240

43-
@Test
44-
public void test2() {
45-
t1 = TreeUtils.constructBinaryTree(Arrays.asList(1, 3, 2, 5));
46-
47-
t2 = TreeUtils.constructBinaryTree(Arrays.asList(2, 1, 3, null, 4, null, 7));
48-
49-
expected = TreeUtils.constructBinaryTree(Arrays.asList(3, 4, 5, 5, 4, null, 7));
50-
51-
actual = solution2.mergeTrees(t1, t2);
52-
53-
assertEquals(expected, actual);
54-
}
5541
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy