Snippets Collections
    int LargButMinFreq(int arr[], int n) {
        // code here
        priority_queue<int> pq;
        for(int i = 0; i < n ; i++){
            pq.push(arr[i]);
        }
        int ans = 0,minFreq = INT_MAX;
        while(!pq.empty()){
            int val = pq.top(),freq = 1;
            pq.pop();
            while(!pq.empty() && pq.top() == val){
                pq.pop() , freq++;
            }
            if(freq < minFreq)
                minFreq = freq, ans = val;
        }
        return ans;
    }
star

Wed May 31 2023 08:14:47 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/frequency-game/1

#c++ #largest_min_freq

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension