Doubt in code for Longest BST in a Binary Tree Problem

Coding Blocks IDE
In the above code, In place of :
if (root->data >= left.leftmax && root->data < right.rightmin &&
left.is_bst && right.is_bst)
{
ans.maxBSTsize = left.maxBSTsize + right.maxBSTsize + 1;
ans.is_bst = true;
ans.leftmax = max(left.leftmax, root->data);
ans.rightmin = min(right.rightmin, root->data);
}
Can we also write this:
ans.leftmax =root->data;
ans.rightmin =root->data

Yes that should be okay.