Fixed: 26 - Sequential Containers

This commit is contained in:
2026-08-16 10:10:37 +03:00
parent 00a5178b01
commit 4314f9126a
3 changed files with 29 additions and 8 deletions
@@ -4,18 +4,38 @@ namespace stl_containers {
auto merge_sorted_vectors(const std::vector<int>& a, const std::vector<int>& b)
-> std::vector<int> {
(void)a; (void)b;
return {};
std::vector<int> v;
auto aIt = a.begin();
auto bIt = b.begin();
while (aIt != a.end() && bIt != b.end()) {
if (*aIt >= *bIt) {
v.push_back(*bIt++);
} else {
v.push_back(*aIt++);
}
}
while (aIt != a.end()) {
v.push_back(*aIt++);
}
while (bIt != b.end()) {
v.push_back(*bIt++);
}
return v;
}
auto list_to_vector(const std::list<int>& data) -> std::vector<int> {
(void)data;
return {};
return std::vector(data.begin(), data.end());
}
auto rotate_deque(std::deque<int> data, int steps) -> std::deque<int> {
(void)data; (void)steps;
return {};
auto rotate_deque(const std::deque<int> &data, const int steps) -> std::deque<int> {
auto result = std::deque{data};
for (auto i = 0; i < steps; ++i) {
// Take from the front, add to the end
auto aux = result.front();
result.push_back(aux);
result.pop_front();
}
return result;
}
} // namespace stl_containers