Tournament Tree Second Value
Page 1 of 1
Tournament Tree Second Value
public static Integer recurse(BTreeNode root) {
if(root.left == null || root.right == null)
return Integer.MAX_VALUE;
int res;
if(root.left.val == root.val)
res = Math.min(root.right.val, recurse(root.left));
else
res = Math.min(root.left.val, recurse(root.right));
return res;
}
if(root.left == null || root.right == null)
return Integer.MAX_VALUE;
int res;
if(root.left.val == root.val)
res = Math.min(root.right.val, recurse(root.left));
else
res = Math.min(root.left.val, recurse(root.right));
return res;
}
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|