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
Node.val
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
Node.val