C_o_d_e__'s blog

By C_o_d_e__, history, 6 months ago, In English

lets we have

string s="" , k="abcd";

(1) s=s+a;

(2) s+=a;

  • Vote: I like it
  • -1
  • Vote: I do not like it

»
6 months ago, # |
Rev. 2   Vote: I like it +3 Vote: I do not like it

s=s+a; creates a copy of the string so you can get MLE,

s+=a or s.append(a) doesnt creates a copy of the string.