Solved: 23 - Associative Containers
This commit is contained in:
@@ -4,18 +4,25 @@ namespace stl_containers {
|
||||
|
||||
auto word_frequencies(const std::vector<std::string>& words)
|
||||
-> std::map<std::string, int> {
|
||||
(void)words;
|
||||
return {};
|
||||
auto m = std::map<std::string, int>();
|
||||
for (const auto& word : words) {
|
||||
++m[word];
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
auto unique_sorted(const std::vector<int>& data) -> std::set<int> {
|
||||
(void)data;
|
||||
return {};
|
||||
auto s = std::set<int>();
|
||||
for (const auto& value : data) {
|
||||
s.insert(value);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
auto invert_map(const std::map<int, std::string>& input) -> std::map<std::string, int> {
|
||||
(void)input;
|
||||
return {};
|
||||
auto m = std::map<std::string, int>();
|
||||
for (const auto&[k, v] : input) m[v] = k;
|
||||
return m;
|
||||
}
|
||||
|
||||
} // namespace stl_containers
|
||||
|
||||
Reference in New Issue
Block a user