8000 refactor 538 · Purva7/Leetcode@9ac4c91 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9ac4c91

Browse files
refactor 538
1 parent d159d7d commit 9ac4c91

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
public class _538 {
3030

31-
public static class BSTSolution {
31+
public static class Solution1 {
3232
/**
3333
* Traverse in this order: right -> root -> left
3434
*/
@@ -46,7 +46,7 @@ private int dfs(TreeNode root, int val) {
4646
}
4747
}
4848

49-
public static class GenericSolution {
49+
public static class Solution2 {
5050
//This solution is generic for both BST and regular binary trees
5151
public TreeNode convertBST(TreeNode root) {
5252
if (root == null) {

src/test/java/com/fishercoder/_538Test.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
import static junit.framework.Assert.assertEquals;
1010

1111
public class _538Test {
12-
private static _538.GenericSolution genericSolution;
13-
private static _538.BSTSolution bstSolution;
12+
private static _538.Solution2 solution2;
13+
private static _538.Solution1 solution1;
1414
private static TreeNode expectedRoot;
1515
private static TreeNode root;
1616

1717
@BeforeClass
1818
public static void setup() {
19-
bstSolution = new _538.BSTSolution();
20-
genericSolution = new _538.GenericSolution();
19+
solution1 = new _538.Solution1();
20+
solution2 = new _538.Solution2();
2121
}
2222

2323
@Before
@@ -32,15 +32,15 @@ public void test1() {
3232
expectedRoot = new TreeNode(18);
3333
expectedRoot.left = new TreeNode(20);
3434
expectedRoot.right = new TreeNode(13);
35-
assertEquals(expectedRoot.toString(), genericSolution.convertBST(root).toString());
36-
assertEquals(expectedRoot.toString(), bstSolution.convertBST(root).toString());
35+
assertEquals(expectedRoot.toString(), solution2.convertBST(root).toString());
36+
assertEquals(expectedRoot.toString(), solution1.convertBST(root).toString());
3737
}
3838

3939
@Test
4040
public void test2() {
4141
root = null;
4242
expectedRoot = null;
43-
assertEquals(expectedRoot, genericSolution.convertBST(root));
44-
assertEquals(expectedRoot, bstSolution.convertBST(root));
43+
assertEquals(expectedRoot, solution2.convertBST(root));
44+
assertEquals(expectedRoot, solution1.convertBST(root));
4545
}
4646
}

0 commit comments

Comments
 (0)
0