题目很nice,写的时候发现没有那么简单!
描述很垃圾,样例也不给,剑指offer系列题一点也不用心!!!

public class Solution {
    String Serialize(TreeNode root) {
        if (root == null) {
            return "#,";
        }
        StringBuilder serString = new StringBuilder();
        serString.append(root.val + ",");
        serString.append(Serialize(root.left));
        serString.append(Serialize(root.right));
        return serString.toString();
    }

    TreeNode Deserialize(String str) {
        if (str == null) {
            return null;
        }
        String[] splitStr = str.split(",");
        return Deserialize(splitStr);
    }

    int index = -1;
    TreeNode Deserialize(String[] splitStr) {
        if (++index == splitStr.length) {
            return null;
        }
        TreeNode node = null;
        if (!splitStr[index].equals("#")) {
            node = new TreeNode(Integer.valueOf(splitStr[index]));
            node.left = Deserialize(splitStr);
            node.right = Deserialize(splitStr);
        }
        return node;
    }
}