Skip to content

Commit 8441e21

Browse files
committed
Refactor custom DS solutions
1 parent 0cf2037 commit 8441e21

File tree

9 files changed

+24
-62
lines changed

9 files changed

+24
-62
lines changed

src/com/andrewbayd/binarySearchTreeLCA/Solution.java renamed to src/com/andrewbayd/BinarySearchTreeLCA.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
package com.andrewbayd.binarySearchTreeLCA;
1+
package com.andrewbayd;
2+
3+
import com.andrewbayd.datastructures.TreeNode;
24

35
/*
46
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.
57
68
https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/
79
*/
810

9-
public class Solution {
11+
public class BinarySearchTreeLCA {
1012

1113
public TreeNode lowestCommonAncestorIterative(TreeNode root, TreeNode p, TreeNode q) {
1214
while (root != null) {

src/com/andrewbayd/binaryTreeInOrderTraversal/Solution.java renamed to src/com/andrewbayd/BinaryTreeInOrderTraversal.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
https://leetcode.com/problems/binary-tree-inorder-traversal/
1010
*/
1111

12-
public class Solution {
12+
public class BinaryTreeInOrderTraversal {
1313
public List<Integer> inorderTraversal(TreeNode root) {
1414
List<Integer> result = new ArrayList<>();
1515
traversalRecursive(root, result);

src/com/andrewbayd/invertBinaryTree/Solution.java renamed to src/com/andrewbayd/InvertBinaryTree.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
package com.andrewbayd.invertBinaryTree;
1+
package com.andrewbayd;
2+
3+
import com.andrewbayd.datastructures.TreeNode;
24

35
/*
46
Given the root of a binary tree, invert the tree, and return its root.
57
68
https://leetcode.com/problems/invert-binary-tree/
79
*/
810

9-
public class Solution {
11+
public class InvertBinaryTree {
1012

1113
public TreeNode invertTree(TreeNode root) {
1214
invertRecursive(root);

src/com/andrewbayd/MergeTwoSortedLists.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
import com.andrewbayd.datastructures.ListNode;
44

5+
/*
6+
Merge the two sorted lists in a one sorted list. The list should be made by splicing together the nodes of the first two lists.
7+
Return the head of the merged linked list.
8+
9+
https://leetcode.com/problems/merge-two-sorted-lists/
10+
*/
11+
512
public class MergeTwoSortedLists {
613
public static ListNode mergeTwoLists(ListNode list1, ListNode list2) {
714
if (list1 == null) return list2;

src/com/andrewbayd/symmetricTree/Solution.java renamed to src/com/andrewbayd/SymmetricTree.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
package com.andrewbayd.symmetricTree;
1+
package com.andrewbayd;
2+
3+
import com.andrewbayd.datastructures.TreeNode;
24

35
/*
46
Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center).
57
68
https://leetcode.com/problems/symmetric-tree/
79
*/
810

9-
public class Solution {
11+
public class SymmetricTree {
1012
public boolean isSymmetric(TreeNode root) {
1113
return isSymetricRecursive(root.left, root.right);
1214
}

src/com/andrewbayd/binarySearchTreeLCA/TreeNode.java

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/com/andrewbayd/binaryTreeInOrderTraversal/TreeNode.java

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/com/andrewbayd/invertBinaryTree/TreeNode.java renamed to src/com/andrewbayd/datastructures/TreeNode.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
package com.andrewbayd.invertBinaryTree;
1+
package com.andrewbayd.datastructures;
22

33
// Definition for a binary tree node.
44
public class TreeNode {
5-
int val;
6-
TreeNode left;
7-
TreeNode right;
5+
public int val;
6+
public TreeNode left;
7+
public TreeNode right;
88

99
TreeNode() {
1010
}

src/com/andrewbayd/symmetricTree/TreeNode.java

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)