Artifact Content
Not logged in

Artifact d8235f29f64235d208760f4a59480ca7a85cb9d1


#include <string>
#include <stack>
using namespace std;

struct MagicSpell
{
	string fixTheSpell( string spell )
	{
		stack<char> s;
		for(int i=0; i<spell.size(); ++i)
			if( spell[i]=='A' || spell[i]=='Z' )
				s.push( spell[i] );
		for(int i=0; i<spell.size(); ++i)
			if( spell[i]=='A' || spell[i]=='Z' )
				spell[i]=s.top(), s.pop();
		return spell;
	}
};