[C++] DFS || Easy Solution with comments
\nclass Solution {\n     int helper(int src,vector<vector<int>>& g,vector<int>& size){\n         int ans = 1;\n         for(auto child:g[src]){\n             an
```\nclass Solution {\n     int helper(int src,vector<vector<int>>& g,vector<int>& size){\n         int ans = 1;\n         for(auto child:g[src]){\n             ans += helper(child,g,size);\n         }\n         return size[src] = ans; \n     }\n    \n    \npublic:\n    int countHighestScoreNodes(vector<int>& parents) {\n        int n = parents.size();\n        vector<int> size(n,0);  // size[i] indicates size of subtree(rooted at i node) + 1\n        vector<vector<int>> g(n); // storing left and right child of a node\n        for(int i=1;i<n;i++){\n            g[parents[i]].push_back(i);\n        }\n        helper(0,g,size);  // calculating size of each subtree\n        long long cnt = 0, maxi = 0;\n        for(int i=0;i<n;i++){\n            long long pro = 1; \n            pro = max(pro,(long long)n - size[i]); // calculating leftover nodes excluding child nodes \n            for(auto node:g[i]){\n                pro = pro * size[node]; // multiplying with size of subtree\n            }\n            if(pro > maxi){\n                maxi = pro;\n                cnt = 1;\n            }\n            else if(pro == maxi){\n                cnt++;\n            }\n        }\n        return cnt;\n    }\n};\n```\n**Hit upvote if you like it :)**
[]