Tap here to switch tabs
Problem
Submissions

Problem: Find All The Lonely Nodes

Find All The Lonely Nodes asks you to return the values of every binary-tree node that is its parent’s only child, excluding the root; values may appear in any order.

Statement

In a binary tree, a lonely node is defined as a node that is the only child of its parent. The root node is never lonely because it does not have a parent.

Given the root of a binary tree, return an array containing the values of all lonely nodes in the tree. The values may be returned in any order.

Constraints:

  • The number of nodes in the tree is in the range [1,1000][1, 1000].

  • 1≤1 \leq Node.val ≤106\leq 10^6

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find All The Lonely Nodes

Find All The Lonely Nodes asks you to return the values of every binary-tree node that is its parent’s only child, excluding the root; values may appear in any order.

Statement

In a binary tree, a lonely node is defined as a node that is the only child of its parent. The root node is never lonely because it does not have a parent.

Given the root of a binary tree, return an array containing the values of all lonely nodes in the tree. The values may be returned in any order.

Constraints:

  • The number of nodes in the tree is in the range [1,1000][1, 1000].

  • 1≤1 \leq Node.val ≤106\leq 10^6