Filter Reddit Comments by User Preference

Problem

Given a Reddit post's comment forest and a user's preference, determine which comments should be retained.

  • If the preference is cat, remove every dog comment and its entire subtree. ...

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: