Easy 2 DFS | Very Intuitive
Code

# Code
```cpp []
#define ll long long
class Solution {
public:
    vector<int>v;
    ll ans;

    void dfs(int node,int par,vector<vector<int>>&adj){
        v[node]=1;
        for(auto child:adj[node]){
            if(child!=par){
               dfs(child,node,adj);
               v[node]+=v[child];
            }
        }   
    }
    void dfs1(int node,int par,vector<vector<int>>&adj,vector<int>&nums,map<ll,int>&mp){
        //parent 
        ll temp=1;
        if(nums[node]!=-1){
           temp = v[0];
           temp-= v[node];
        }
        for(auto child:adj[node]){
            //int temp1=1;
            if(child!=par){
               temp= 1LL*temp*v[child];
            }
        }
        mp[temp]++;
        ans = max(1LL*ans,temp);
        for(auto child:adj[node]){
            if(child!=par){
                dfs1(child,node,adj,nums,mp);
            }
        }
    }
    int countHighestScoreNodes(vector<int>& nums) {
        int n = nums.size();
        vector<vector<int>>adj(n);
        for(int i=1;i<n;i++){
            adj[nums[i]].push_back(i);
            adj[i].push_back(nums[i]);
        }
        v.resize(n+1);
        dfs(0,-1,adj);
        ans = 0;
        map<ll,int>mp;
        dfs1(0,-1,adj,nums,mp);
        return mp[ans];
    }
};
```
['Array', 'Depth-First Search', 'Binary Tree', 'C++']