C++ Easy Vector<priority_queue> Solution
Intuition\n Describe your first thoughts on how to solve this problem. \nUse priority queue to store values of associated nodes \n\n# Approach\n Describe your a
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nUse priority queue to store values of associated nodes \n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. For each node maintain a max priority queue of values of nodes connected with it.\n2. Traverse and check the maximum value \n\n# Complexity\n- Time complexity: \n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int maxStarSum(vector<int>& vals, vector<vector<int>>& fs, int k) {\n        int n=vals.size();\n        vector<priority_queue<int>> edges(n);\n        \n        //Fill Up data structures \n        for(int i=0;i<fs.size();i++){\n            int f,s;\n            f=fs[i][0];\n            s=fs[i][1];\n            \n            edges[f].push(vals[s]);\n            edges[s].push(vals[f]);\n        }\n        \n        int ans=INT_MIN;\n        for(int i=0;i<n;i++){\n            int prev=vals[i], current=vals[i];\n            int num=k;\n            \n            //Getting answer from each priority queue \n            while(num>0 && !edges[i].empty()){\n                prev=current;\n                current+=edges[i].top();\n                edges[i].pop();\n                \n                if(current<prev){\n                    current=prev;\n                    break;\n                }\n                num--;\n            }\n            ans=max(ans,current);\n        }        \n        return ans;\n    }\n};\n```
['Heap (Priority Queue)', 'C++']