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 | 3856 |
2 | jiangly | 3747 |
3 | orzdevinwang | 3706 |
4 | jqdai0815 | 3682 |
5 | ksun48 | 3591 |
6 | gamegame | 3477 |
7 | Benq | 3468 |
8 | Radewoosh | 3462 |
9 | ecnerwala | 3451 |
10 | heuristica | 3431 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | -is-this-fft- | 162 |
3 | Dominater069 | 160 |
4 | Um_nik | 158 |
5 | atcoder_official | 157 |
6 | Qingyu | 156 |
7 | adamant | 151 |
7 | djm03178 | 151 |
7 | luogu_official | 151 |
10 | awoo | 146 |
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.