Build a Playlist. Write add(song): if the playlist already has that song (exactly the same name), don't add it; otherwise put it at the end. playlist_size adds the songs one by one and returns how many the playlist has.
playlist_size({"Yellow", "Hello", "Yellow"})→2playlist_size({})→0int playlist_size(const vector<string> &adds)#include <string>
#include <vector>
using namespace std;
class Playlist {
public:
vector<string> songs;
void add(const string &song) {
// your code here: add to songs only if it isn't there
}
};
int playlist_size(const vector<string> &adds) {
Playlist p;
for (const string &s : adds) {
p.add(s);
}
return p.songs.size();
}
Run tries the examples. When they look right, Submit.