Given a linked list containing duplicate elements. The task is to find the count of all minimum occurring elements in the given linked list. That is the count of all such elements whose frequency is minimum in the matrix.
Input : 1-> 2-> 2-> 3 Output : 2 Explanation: 1 and 3 are elements occurs only one time. So, count is 2. Input : 10-> 20-> 20-> 10-> 30 Output : 1
- Traverse the linked list and use a hash table to store the frequency of elements of the linked list such that the key of map is the linked list element and value is its frequency in the linked list.
- Then traverse the hash table to find the minimum frequency.
- Finally, traverse the hash table to find the frequency of elements and check if it matches with the minimum frequency obtained in previous step, if yes, then add this frequency to count.
Below is the implementation of the above approach:
Time Complexity : O(n)
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Maximum length prefix such that frequency of each character is atmost number of characters with minimum frequency
- Maximum difference between frequency of two elements such that element having greater frequency is also greater
- Count of Binary Strings of length N such that frequency of 1's exceeds frequency of 0's
- Generate a number such that the frequency of each digit is digit times the frequency in given number
- Check if frequency of character in one string is a factor or multiple of frequency of same character in other string
- Sum of all odd frequency nodes of the Linked List
- Find the element in a linked list with frequency at least N/3
- XOR Linked List - A Memory Efficient Doubly Linked List | Set 1
- XOR Linked List – A Memory Efficient Doubly Linked List | Set 2
- Merge a linked list into another linked list at alternate positions
- Check if a linked list is Circular Linked List
- Convert singly linked list into circular linked list
- Difference between Singly linked list and Doubly linked list
- Convert Singly Linked List to XOR Linked List
- Create new linked list from two given linked list with greater element at each node
- Sum of all minimum frequency elements in Matrix
- Partitioning a linked list around a given value and If we don't care about making the elements of the list "stable"
- Count the elements having frequency equals to its value
- Count the elements having frequency equals to its value | Set 2
- Find minimum and maximum elements in singly Circular Linked List
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.