Java concise Solution.
\npublic class Codec {\n\n    // Encodes a tree to a single string.\n    public String serialize(TreeNode root) {\n        if(root == null){\n            return
```\npublic class Codec {\n\n    // Encodes a tree to a single string.\n    public String serialize(TreeNode root) {\n        if(root == null){\n            return "#";\n        }\n        return String.valueOf(root.val) + "," + serialize(root.left) + "," + serialize(root.right);\n    }\n\n    // Decodes your encoded data to tree.\n    public TreeNode deserialize(String data) {\n        String[]strs = data.split(",");\n        return deserialize(strs, new int[]{0});\n    }\n    private TreeNode deserialize(String[]arr, int[]idx){\n        if(arr[idx[0]].equals("#")){\n            idx[0]++;\n            return null;\n        }\n        TreeNode root = new TreeNode(Integer.parseInt(arr[idx[0]++]));\n        root.left = deserialize(arr, idx);\n        root.right = deserialize(arr, idx);\n        return root;\n    }\n}\n```
[]