An in-place algorithm for String Transformation

PHOTO EMBED

Thu Sep 29 2022 09:37:51 GMT+0000 (UTC)

Saved by @Ranjan_kumar #c++

#include <bits/stdc++.h>

using namespace std;

int main()
{
   string s="a1b2c3d4e5f6g7h8i9j1k2l3m4";
   string w1="";
   string w2="";
   int n=s.size();
   for(int i=0;i<n;i++)
   {
       if(i%2==0) {w1+=s[i];}
       else w2+=s[i];
   }
   cout<<w1+w2<<"\n";
   cout<<w1.append(w2);
    return 0;
}
content_copyCOPY

https://www.geeksforgeeks.org/an-in-place-algorithm-for-string-transformation/