Find All Binary Tree Nodes at Distance K

Given the root of a binary tree, a target node in that tree, and a non-negative integer K, return the values of all nodes at distance exactly K from target, in any order.

Each edge has leng...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: