<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Tree on Code Mirroring</title><link>https://www.codemirroring.com/ds-algo/tree/</link><description>Recent content in Tree on Code Mirroring</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><atom:link href="https://www.codemirroring.com/ds-algo/tree/index.xml" rel="self" type="application/rss+xml"/><item><title>Lowest Common Ancestor of a Binary Tree</title><link>https://www.codemirroring.com/ds-algo/tree/lowest-common-ancestor-of-a-binary-tree/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://www.codemirroring.com/ds-algo/tree/lowest-common-ancestor-of-a-binary-tree/</guid><description>Problem statement Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.
According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a node to be a descendant of itself).”
Example:
Input:
root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 1 Expected output:</description></item></channel></rss>