Hands of Straights Coding Solution Geeks for Geeks Problem of the Day 20 May 2023 GFG POTD Solution Today Gfg problem of the day solution with explanation C++ class Solution { public: bool isStraightHand(int n, int k, vector &v) { // k= group size if(n%k>0){ return false; } map mp; for(auto it:v){ mp[it]++; } // put all the size() with its frquency in the (min)p_queue priority_queue , vector >, greater > > pq; for(auto it:mp){ pq.push({it.first,it.second}); } int cnt=0; int last=-1; queue > q; while(pq.size()>0){ int t=pq.top().first; int val=pq.top().second; pq.pop(); // take top ele of the heap and check if the last element and // the top element are coincidnt if not return false // if yes then put the last ele to curr op e...
Job Alerts, Coding Solutions, Interview Material, Placement Material