category-wise-problems

contains category wise problems(data structures, competitive) of popular platforms.

View the Project on GitHub mayankdutta/category-wise-problems

543. Diameter of Binary Tree

code ```cpp class Solution { public: int diameterOfBinaryTree(TreeNode* root) { int ans = 0; auto diameter = [&](const auto& self, const auto& root) -> int { if (root == nullptr) return 0; int left = self(self, root -> left); int right = self(self, root -> right); ans = max({ans, left + right}); return max(left, right) + 1; }; diameter(diameter, root); return ans; } }; ```