Initially C++ present in the tags… Test can be on cpp.sh
#include <iostream>
#include <vector>
int main()
{
std::string algorithm_sorting ("1101001011");
std::vector <std::string> video = {"a1","a2","a3","a4"};
std::vector <std::string> picture = {"b1","b2","b3","b4"};
std::vector <std::string> result;
size_t v = 0, p = 0;
for(auto&x:algorithm_sorting)
{
if(x=='1')
{
if(v < video.size()) result.push_back(video[v]);
v++;
}
else
{
if( p < picture.size()) result.push_back(picture[p]);
p++;
}
}
for(auto&x:result)std::cout<<x<<" ";
}
2
solved algorithm sorting 1101001011