breadth-first search

#2

Day 2

Photo by Chris Barbalis on Unsplash

The Problem

Two nodes in a binary tree can be called cousins if they are on the same level of the tree but have different parents. For example, in the following diagram 4 and 6 are cousins.

    1
   / \
  2   3
 / \   \
4   5   6

Given a binary tree and a particular node, find all cousins of that node.

https://dailycodingproblem.com
Read More »#2