Given an array of size N and a Linked List where elements will be from the array but can also be duplicated, sort the linked list in the order, elements are appearing in the array. It may be assumed that the array covers all elements of the linked list.
Sorted list =
Asked in Amazon
First, make a hash table that stores the frequencies of elements in linked list. Then, simply traverse list and for each element of arr[i] check the frequency in the has table and modify the data of list by arr[i] element upto its frequency and at last Print the list.
Sort list: 5 -> 5 -> 1 -> 3 -> 2 -> 2 -> 8
- Replace even nodes of a doubly linked list with the elements of array
- Sort even-placed elements in increasing and odd-placed in decreasing order
- Partitioning a linked list around a given value and If we don't care about making the elements of the list "stable"
- Partitioning a linked list around a given value and keeping the original order
- Print Doubly Linked list in Reverse Order
- Sort a linked list of 0s, 1s and 2s
- Sort an array where a subarray of a sorted array is in reverse order
- Sort Linked List containing values from 1 to N
- Merge two sorted linked lists such that merged list is in reverse order
- Sort the biotonic doubly linked list
- Insertion Sort for Singly Linked List
- Sort the biotonic doubly linked list | Set-2
- Bubble Sort On Doubly Linked List
- C Program for Bubble Sort on Linked List
- Merge Sort for Doubly 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 firstname.lastname@example.org. 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.