Company: Accolite_11oct
Difficulty: medium
Festival of Spirits - Eywa's Festival Problem Description On Pandora, the Na'vi tribes care for N sacred sites, numbered 0 to N - 1 . The sites are linked by pathways into a binary tree whose root is the Great Tree at site 0 . Every site has at most two child sites: a left child and a right child. The network grew one discovery at a time. When a new site is connected under a parent site, it takes the parent's left slot if that slot is still free; otherwise it takes the right slot. The pathways are listed in the order they were discovered, so for each parent the first pathway that names it gives its left child and the second gives its right child. A site with a single child always has that child on its left. The Book of Souls records guardians[i] , the number of Na'vi guardians at site i . To choose the host of Eywa's Festival, the tribes walk the network in inorder : the left subtree of a site first, then the site itself, then its right subtree, starting from site 0 . The M -th site vi