Untitled
unknown
plain_text
10 months ago
381 B
3
Indexable
private boolean validate(TreeNode node, long min, long max) {
if (node == null) return true;
// Check the current node's value against the range
if (node.val <= min || node.val >= max) return false;
// Recursively validate the left and right subtrees
return validate(node.left, min, node.val) && validate(node.right, node.val, max);
}Editor is loading...
Leave a Comment