### Hepic_Antony_Skarlatos's blog

By Hepic_Antony_Skarlatos, 7 years ago,

I was practising in a problem here in codeforces,and I wanted to train my C# skills a bit. So I wrote an answer about the problem,and when I tested it throwed "time limit exceed". I was curious about a faster way,so I checked 2-3 another sources,and I found a very similar one in C++. So I wrote the same program in C++,and my answer was accepted.

Why happened that?

• 0

 » 7 years ago, # |   0 Your submission list shows no attempts in C#.
•  » » 7 years ago, # ^ |   +2 click "show unofficial"
•  » » 7 years ago, # ^ | ← Rev. 2 →   +3 Your C# code TLs because these operations in .Net have O(len(str)) complexity: str1 += "1"; str2 += "1"; str1 += (check1[i] ? "1" : "0"); str2 += (check2[i] ? "1" : "0"); Read about strings in .Net and about StringBuilder class.
•  » » » 7 years ago, # ^ | ← Rev. 2 →   0 Ohh that sounds interesting,but what you would suggest to fix that? You suggest to use that "StringBuilder" ?
•  » » » » 7 years ago, # ^ |   +3 Yes, StringBuilder will allow you to use that approach you used with the performance you thought it would have.