ขนาดวิดีโอ: 1280 X 720853 X 480640 X 360
แสดงแผงควบคุมโปรแกรมเล่น
เล่นอัตโนมัติ
เล่นใหม่
give him a crown🌟
Thank You 😊
please solve this one: Selling Pieces of Wood
Thank you bhayia
public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) { if(root == null || root == p || root == q) return root; TreeNode leftLca = lowestCommonAncestor(root.left, p, q); TreeNode rightLca = lowestCommonAncestor(root.right, p, q); if(leftLca == null) return rightLca; if(rightLca == null) return leftLca; return root; }
give him a crown🌟
Thank You 😊
please solve this one: Selling Pieces of Wood
Thank you bhayia
public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) {
if(root == null || root == p || root == q) return root;
TreeNode leftLca = lowestCommonAncestor(root.left, p, q);
TreeNode rightLca = lowestCommonAncestor(root.right, p, q);
if(leftLca == null) return rightLca;
if(rightLca == null) return leftLca;
return root;
}