# Count the nodes of the tree which make a pangram when concatenated with the sub-tree nodes

Given a tree, and the weights (in the form of strings) of all the nodes, the task is to count the nodes whose weighted string when concatenated with the strings of the sub-tree nodes becomes a pangram.
Pangram: A pangram is a sentence containing every letter of the English Alphabet.

Examples:

Input: Output: 1
Only the weighted string of sub-tree of node 1 makes the pangram.

## Recommended: Please try your approach on {IDE} first, before moving on to the solution.

Approach: Perform dfs on the tree and update the weight of every node such that it stores its weight concatenated with the weights of the sub-tree nodes. Then, count the nodes whose updated weighted string forms a pangram.

Below is the implementation of the above approach:

 `// C++ implementation of the approach ` `#include ` `using` `namespace` `std; ` ` `  `vector<``int``> graph; ` `vector weight(100); ` ` `  `// Function that returns if the ` `// string x is a pangram ` `bool` `Pangram(string x) ` `{ ` `    ``map<``char``, ``int``> mp; ` `    ``int` `n = x.size(); ` ` `  `    ``for` `(``int` `i = 0; i < n; i++) ` `        ``mp[x[i]]++; ` `    ``if` `(mp.size() == 26) ` `        ``return` `true``; ` `    ``else` `        ``return` `false``; ` `} ` ` `  `// Function to return the count of nodes ` `// which make pangram with the ` `// sub-tree nodes ` `int` `countTotalPangram(``int` `n) ` `{ ` `    ``int` `cnt = 0; ` `    ``for` `(``int` `i = 1; i <= n; i++) ` `        ``if` `(Pangram(weight[i])) ` `            ``cnt++; ` `    ``return` `cnt; ` `} ` ` `  `// Function to perform dfs and update the nodes ` `// such that weight[i] will store the weight[i] ` `// concatenated with the weights of ` `// all the nodes in the sub-tree ` `void` `dfs(``int` `node, ``int` `parent) ` `{ ` ` `  `    ``for` `(``int` `to : graph[node]) { ` `        ``if` `(to == parent) ` `            ``continue``; ` `        ``dfs(to, node); ` `        ``weight[node] += weight[to]; ` `    ``} ` `} ` ` `  `// Driver code ` `int` `main() ` `{ ` `    ``int` `n = 6; ` ` `  `    ``// Weights of the nodes ` `    ``weight = ``"abcde"``; ` `    ``weight = ``"fghijkl"``; ` `    ``weight = ``"abcdefg"``; ` `    ``weight = ``"mnopqr"``; ` `    ``weight = ``"stuvwxy"``; ` `    ``weight = ``"zabcdef"``; ` ` `  `    ``// Edges of the tree ` `    ``graph.push_back(2); ` `    ``graph.push_back(3); ` `    ``graph.push_back(4); ` `    ``graph.push_back(5); ` `    ``graph.push_back(6); ` ` `  `    ``dfs(1, 1); ` ` `  `    ``cout << countTotalPangram(n); ` ` `  `    ``return` `0; ` `} `

Output:

```1
```

My Personal Notes arrow_drop_up 