xiaomi/3.cc
// return the length of longest path from root to a leaf node
return the length of longest path from root to a leaf node
return the length of longest path from root to a leaf node
int helper(Node *root) {
	int left = 0, right = 0;
	if (root->left)
		left = helper(root->left);
	if (root->right)
		right = helper(root->right);
	if (left && right && left + right > dist)
		dist = left + right;
	return std::max(left, right);
}
int helper ( Node * root ) { int left = 0 , right = 0 ; if ( root -> left ) left = helper ( root -> left ) ; if ( root -> right ) right = helper ( root -> right ) ; if ( left && right && left + right > dist ) dist = left + right ; return std :: max ( left , right ) ; }
return the length of longest path from root to a leaf node
return the length of longest path from root to a leaf node
// update the maximum distance between two leaves