Advertisers run marketing campaigns that target users in specific geographic regions. These regions form a fixed hierarchy. For example:
"World"contains"Europe"and"US"."Europe"contains"France"and"Germany"."France"contains"Paris"and"Nice"and so on.
When an advertiser is granted access to a region, they automatically gain permission to all of its subregions. Likewise, revoking access to a region removes permission for that region and every subregion beneath it. You are asked to design a system that efficiently performs these grant and revoke operations for any advertiser and any region in the hierarchy.
Ask AI Assistant

Ask AI Assistant
Ask me anything about this coding question!
Test Cases
Input
Output
Expected