funcdiameterOfBinaryTree(_root: TreeNode?) -> Int { var maxValue =0 funcdfs(_cur: TreeNode?) -> Int { guardlet cur = cur else { return0 } let left = dfs(cur.left) let right = dfs(cur.right) maxValue =max(maxValue, left + right) returnmax(left, right) +1 } dfs(root) return maxValue }