foundX
and foundY
, to false
.
b. For each level, iterate over the nodes in the queue.
c. For each node, check if its children are x
or y
.
x
, set foundX
to true
.y
, set foundY
to true
.
d. If both foundX
and foundY
are true
at the end of the level, return true
.
e. If only one is found, continue to the next level.false
.