# Weekly Problem SortedFreqs

### Problem Statement

The frequency with which data occurs is sometimes an important statistic. In this problem you'll determine how frequently strings occur and return a vector representing the frequencies of each different/unique string. The vector returned contains as many frequencies as there are unique strings. The returned frequencies represent an alphabetic/lexicographic ordering of the unique words, so the first frequency is how many times the alphabetically first word occurs and the last frequency is the number of times the alphabetically last word occurs.

Consider these strings (quotes for clarity, they're not part of the strings).

```
{"apple", "pear", "cherry", "apple", "cherry", "pear", "apple", "banana"}

```
The vector returned is `{3,1,2,2}` since the alphabetically first word is `"apple"` which occurs 3 times; the second word alphabetically is `"banana"` which occurs once, and the other words each occur twice.

### Definition

• Class: SortedFreqs
• Method: freqs
• Parameters: ` tvector<string>`
• Returns: ` tvector<int;>`
• Method signature:
```   tvector<int> freqs(const tvector<string>& data)
```
(be sure your method is public)

### Class

#include <string> using namespace std; #include "tvector.h" class SortedFreqs { public: tvector<int> freqs(const tvector<string>& data) { // fill in code here } };

None

### Constraints

• data will contain at most 50 elements

• each element of data will contain at most 50 characters, all characters are lowercase.

### Examples

1. ```
data = {"apple", "pear", "cherry", "apple", "cherry", "pear", "apple", "banana"}

```
Returns: {3,1,2,2}

This is the example given above.

2. ```data = {"a","b","c",d"}
```

Returns {1,1,1,1}

3. ```data = {"a","a","a"}
```

Returns {3}

Owen L. Astrachan