Move hash to front
Move Hash to Front
You have write a function that accepts, a string which length is “len”, the string has some “#”, in it you have to move all the hashes to the front of the string and return the whole string back and print it.
Input :
Move#Hash#to#Front
Output :
###MoveHashtoFront
Following is sample CPP code.
#include <iostream>
using namespace std;
int main()
{
string s;
cin>>s;
string ans="";
for(auto i:s){
if(i=='#'){
ans='#'+ans;
}
else{
ans+=i;
}
}
cout<<ans;
}