Loading problem…
You're building a file system explorer that needs to list all files and folders accessible from a root directory.
Given the root of an N-ary tree, return all reachable node values in level-order (BFS).
Level-order means:
node.children> Note: A DFS traversal can reach all nodes, but it will produce a different order for many test cases.
// Tree structure:
// 1
// / | \
// 2 3 4
// /| |
// 5 6 7
findReachableNodes(root);
// [1, 2, 3, 4, 5, 6, 7]
// BFS level-order outputThis problem models practical tree traversal scenarios: