Filter nested comments and keep only matched nodes and their descendants
Implement filtering on a nested comment tree.
Given:
- A nested comment tree (or forest)
roots, each node hascontentandchildren. - A predicate (e.g., content contains keyword q, or userId ==...
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:
