Identifying the lowest common ancestor pattern


The lowest common ancestor finding technique can only solve certain types of binary tree problems. These are generally easy or medium problems where we need to find the lowest common ancestor for a set of nodes in a tree. Finding the lowest common ancestor may directly solve the problem or only a part of it.

If the problem statement or its solution follows the generic template below, it can be solved using the lowest common ancestor finding technique.

Template:

Given a binary tree and a set of nodes, find the lowest common ancestor node.

Liking the course? Check our discounted plans to continue learning.