严氏北美IT公司面试真题汇总和解答论坛
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Tournament Tree Second Value

Go down

Tournament Tree Second Value Empty Tournament Tree Second Value

Post by Admin Sat Oct 21, 2017 4:18 pm

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;
}

Admin
Admin

Posts : 124
Join date : 2017-10-21

https://csinterviewquestions.forumotion.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum