diff --git a/README.md b/README.md index 24391cf..a006289 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ ## 关于本书 -本书致力于达成以下目标: +本书面向数据结构与算法初学者,致力于达成以下目标: - 开源免费,所有同学都可在网上获取本书; - 新手友好,适合算法初学者自主学习入门; diff --git a/codes/java/include/TreeNode.java b/codes/java/include/TreeNode.java index bba76b1..6541064 100755 --- a/codes/java/include/TreeNode.java +++ b/codes/java/include/TreeNode.java @@ -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 queue = new LinkedList<>() {{ add(root); }}; int i = 1; diff --git a/codes/python/include/binary_tree.py b/codes/python/include/binary_tree.py index d905d82..24acb47 100644 --- a/codes/python/include/binary_tree.py +++ b/codes/python/include/binary_tree.py @@ -24,7 +24,7 @@ def list_to_tree(arr): [type]: [description] """ if not arr: - return + return None i = 1 root = TreeNode(int(arr[0])) queue = collections.deque()