Question: You are tasked with writing a function that takes in a vector of integers and returns a new vector, sorted based on the frequency of

You are tasked with writing a function that takes in a vector of integers and returns a new vector, sorted based on the frequency of the integers in descending order. If two numbers have the same frequency, the larger number appears first. Let's illustrate what we mean by example. In the following examples, we use the notation [2,4,6] to show the composition of a vector. In [2,4,6],2 resides at index 0,4 at index 1, and so on.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!