修改包的名字
This commit is contained in:
parent
96ea15ef65
commit
853a073b65
@ -1,4 +1,4 @@
|
|||||||
package com.ossez.lang.tutorial;
|
package com.ossez.codebank.algorithm;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
@ -1,16 +1,16 @@
|
|||||||
package com.ossez.lang.tutorial.models;
|
package com.ossez.codebank.algorithm.models;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author YuCheng
|
* @author YuCheng
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ListNode {
|
public class ListNode {
|
||||||
public int val;
|
public int val;
|
||||||
public ListNode next;
|
public ListNode next;
|
||||||
|
|
||||||
public ListNode(int x) {
|
public ListNode(int x) {
|
||||||
val = x;
|
val = x;
|
||||||
next = null;
|
next = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,16 +1,16 @@
|
|||||||
package com.ossez.lang.tutorial.models;
|
package com.ossez.codebank.algorithm.models;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author YuCheng
|
* @author YuCheng
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TreeNode {
|
public class TreeNode {
|
||||||
public int val;
|
public int val;
|
||||||
public TreeNode left, right;
|
public TreeNode left, right;
|
||||||
|
|
||||||
public TreeNode(int val) {
|
public TreeNode(int val) {
|
||||||
this.val = val;
|
this.val = val;
|
||||||
this.left = this.right = null;
|
this.left = this.right = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.ossez.lang.tutorial.objplusclass;
|
package com.ossez.codebank.algorithm.objplusclass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
@ -1,4 +1,4 @@
|
|||||||
package com.ossez.lang.tutorial.overview;
|
package com.ossez.codebank.algorithm.overview;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Java Tutorial
|
* Java Tutorial
|
@ -1,4 +1,4 @@
|
|||||||
package com.ossez.lang.tutorial.overview;
|
package com.ossez.codebank.algorithm.overview;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Java Tutorial
|
* Java Tutorial
|
@ -1,55 +0,0 @@
|
|||||||
package com.ossez.lang.tutorial.utils;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import com.ossez.lang.tutorial.models.TreeNode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author YuCheng
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class TreeUtils {
|
|
||||||
|
|
||||||
public static TreeNode initTree(String data) {
|
|
||||||
// NULL CHECK
|
|
||||||
if (data.equals("{}")) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayList<TreeNode> treeList = new ArrayList<TreeNode>();
|
|
||||||
|
|
||||||
data = data.replace("{", "");
|
|
||||||
data = data.replace("}", "");
|
|
||||||
String[] vals = data.split(",");
|
|
||||||
|
|
||||||
// INSERT ROOT
|
|
||||||
TreeNode root = new TreeNode(Integer.parseInt(vals[0]));
|
|
||||||
treeList.add(root);
|
|
||||||
|
|
||||||
int index = 0;
|
|
||||||
boolean isLeftChild = true;
|
|
||||||
for (int i = 1; i < vals.length; i++) {
|
|
||||||
if (!vals[i].equals("#")) {
|
|
||||||
TreeNode node = new TreeNode(Integer.parseInt(vals[i]));
|
|
||||||
if (isLeftChild) {
|
|
||||||
treeList.get(index).left = node;
|
|
||||||
} else {
|
|
||||||
treeList.get(index).right = node;
|
|
||||||
}
|
|
||||||
treeList.add(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
// LEVEL
|
|
||||||
if (!isLeftChild) {
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// MOVE TO RIGHT OR NEXT LEVEL
|
|
||||||
isLeftChild = !isLeftChild;
|
|
||||||
}
|
|
||||||
|
|
||||||
return root;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user