Prune an N-ary Tree to a Maximum Depth

Given a rooted N-ary tree and an integer k:

  1. Return the maximum depth of the tree.
  2. Delete as few nodes as possible so that the remaining tree has maximum depth at most k.

Use the following ...

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: