A Disk stores hierarchical data in an undirected tree-like structure with tree_nodes nodes numbered from 0 to tree_nodes - 1 and rooted at node 0. Each node has a character value represented by the array A of length tree_nodes where A[i] denotes the character on the ith node.
You are also given array queries of length m. For each query queries[i], the task is to tell how many nodes v (including queries[i]) are there on the path from queries[i] to root, such that we can arrange the letters on the nodes on the path from queries[i] to v(both inclusive) to form a palindrome.
Return an integer array of size m denoting the answer to each query.
Note: A palindrome is a string that reads the same backward as forward, for example, strings "z", "aaa", "aba", "abccba" are palindromes, but strings "hackerrank", "reality", "ab" are not.
Consider the following example: tree_nodes = 4. A = ["z","a","a","a"] tree_from = [0, 0, 1] tree_to = [1, 2, 3] m = 1 queries = [3]