Why My NNLog(N) soln got tle for 3rd Q , When N= 1000 , It should work , https://leetcode.com/problems/smallest-substring-with-identical-characters-i/solutions/6172861/need-help-why-2-n-n-log-n-solution-not-passed/ , Can anybody help.
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
Why My NNLog(N) soln got tle for 3rd Q , When N= 1000 , It should work , https://leetcode.com/problems/smallest-substring-with-identical-characters-i/solutions/6172861/need-help-why-2-n-n-log-n-solution-not-passed/ , Can anybody help.
Name |
---|
I had similar idea, but was getting TLE. Try switching the dimensions of your vector. TLE Code AC Code
Why TLE? Leetcode runs 1000s of testcases for different values of n in a tight timelimit.
Why vector of size n * 2 gives TLE but 2 * n doesn't? Cache friendliness :)
Ok. Thanks, But still ,If it is having correct TC according to given constraint , It should work I think, Because 2*1e7 operation are performed.
Leetcode has a "combined" time limit for all the testcases in a problem. If you try to add the TLE test case to sample testcases and run it — it will work fine. But if you run 10s of such large testcases, it will cross the time limit, hence the TLE when running all testcases.
Oh .. I get It , Thanks.
Thank you Bhai , I checked 2*n solution worked.