why my this code 118446438 get Time limit exceeded and this code 118446206 get accepted in problem 1535C - Unstable String
any hint
why my this code 118446438 get Time limit exceeded and this code 118446206 get accepted in problem 1535C - Unstable String
any hint
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3690 |
2 | jiangly | 3647 |
3 | Benq | 3581 |
4 | orzdevinwang | 3570 |
5 | Geothermal | 3569 |
5 | cnnfls_csy | 3569 |
7 | Radewoosh | 3509 |
8 | ecnerwala | 3486 |
9 | jqdai0815 | 3474 |
10 | gyh20 | 3447 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | maomao90 | 171 |
2 | adamant | 164 |
3 | awoo | 163 |
4 | TheScrasse | 159 |
5 | nor | 157 |
6 | maroonrk | 155 |
7 | -is-this-fft- | 152 |
8 | Petr | 147 |
9 | orz | 145 |
9 | pajenegod | 145 |
Название |
---|
for(int i=0 ; i<strlen(s) ; i++)
strlen(s)
has $$$O(n)$$$ complexity so this whole loop has $$$O(n^2)$$$ complexity.strlen() is O(n)
the way strlen works is that it will scan and count, until it finds a null character: every time you call strlen, it scans again and again from the beginning, so it's inefficient, while s.size() is constant