private void dfs(TreeNode node, List<String> res, String path) {
        if (node.left == null && node.right == null) {
            res.add(path + node.val);
        } else {
            if (node.left != null) {
                dfs(node.left, res, path + node.val + "->");
            }

            if (node.right != null) {
                dfs(node.right, res, path + node.val + "->");
            }
        }
    }