首页 > TAG信息列表 > 1644

LeetCode 1644. Lowest Common Ancestor of a Binary Tree II

原题链接在这里:https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-ii/ 题目: Given the root of a binary tree, return the lowest common ancestor (LCA) of two given nodes, p and q. If either node p or q does not exist in the tree, ret

1644. Lowest Common Ancestor of a Binary Tree II

When we get this problem, we need to confirm the following 2 questions: 1. Can root, p or q be null? (No) 2. Are both p and q in the tree (No, either p or q mignt not in the tree), this is the only difference with 236. Lowest Common Ancestor of a Binary T