+ 1
Sort the Array by frequency. Help me how this works!
https://www.geeksforgeeks.org/sort-array-according-order-defined-another-array/ I know C and am trying to write the program(c++) into C please clarify the function of mycomp and mycomp2 in the above program if you have any algo able to implement in c to sort by frequency please share
1 Odpowiedź
+ 2
Naive approach
Use three loops
First use to change the index of current element
Second search the above element from 0 to n-1
Third approach search if the current element is present before current index
Don't print the frequency
Efficient way
Use hash map to store the frequency