Diameter of Binary Tree Solutions in PythonNumber 543Difficulty EasyAcceptance 48.4%Link LeetCodeOther languages C++SolutionsPython solution by haoel/leetcodedef diameterOfBinaryTree(self, root): self.res = 0 def helper(root): if not root: return 0 left, right = helper(root.left), helper(root.right) self.res = max(self.res, left + right) return 1 + max(left, right) helper(root) return self.resdef diameterOfBinaryTree(self, root): self.res = 0 def helper(root): if not root: return 0 left, right = helper(root.left), helper(root.right) self.res = max(self.res, left + right) return 1 + max(left, right) helper(root) return self.res