Algorithm · Confluent · Medium
You are given a hierarchy of monsters arranged as an n-ary tree. Every monster has a unique name, a collection of monsters it can defeat, and a hostile flag. A monster whose name is followed by an asterisk ("*") is hostile. Given the monsters and the root monster, return every non-hostile monster that can defeat all hostile monsters in the hierarchy. Each monster contains: name: A string containing the monster's name. isHostile: A boolean that is true for a hostile monster…
Checking your access…