stringcleanString(strings){stringans="";// the answer stringintlength=0;// length of answer stringfor(charc:s){if(c=='#'){// if c == '#' and length > 0, then pop one character and decrement lengthif(length>0){ans.pop_back();length--;}}// else add the character to string and increment lengthelse{ans+=c;length++;}}returnans;}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hope this is right, C++