1.
#include<iostream>
#include<algorithm>
#include<string>
#include<bits/stdc++.h>
using namespace std;
string a,b;
void solve (string x,string y){
if(!(int)y.size()) return;
int pos = x.find(y[0]);
solve(x.substr(0, pos), y.substr(1, pos));
solve(x.substr(pos + 1), y.substr(pos + 1));
printf("%c", y[0]);
return;
}
int main(){
cin>>a>>b;
solve(a,b);
return 0;
}
2.#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
string a,b;
void dfs(string x,string y){
if(!(int)y.size()) return;
int pos=x.find(y[y.size()-1]);
cout<<x[pos];
dfs(x.substr(0,pos),y.substr(0,pos));
dfs(x.substr(pos+1),y.substr(pos,y.size()-pos-1));
return ;
}
int main(){
cin>>a>>b;
dfs(a,b);
return 0;
}