mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-22 15:53:50 +08:00
Fix the util of array to tree.
This commit is contained in:
@ -26,6 +26,9 @@ public class TreeNode {
|
||||
* @return
|
||||
*/
|
||||
public static TreeNode arrToTree(Integer[] arr) {
|
||||
if (arr.length == 0)
|
||||
return null;
|
||||
|
||||
TreeNode root = new TreeNode(arr[0]);
|
||||
Queue<TreeNode> queue = new LinkedList<>() {{ add(root); }};
|
||||
int i = 1;
|
||||
|
Reference in New Issue
Block a user