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 | Benq | 3857 |
| 2 | jiangly | 3810 |
| 3 | maroonrk | 3534 |
| 4 | tourist | 3528 |
| 5 | Kevin114514 | 3510 |
| 6 | turmax | 3411 |
| 7 | Um_nik | 3387 |
| 8 | Radewoosh | 3367 |
| 9 | heuristica | 3322 |
| 10 | strapple | 3317 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 157 |
| 2 | maspy | 150 |
| 3 | Um_nik | 145 |
| 4 | Errichto | 139 |
| 5 | adamant | 136 |
| 6 | maroonrk | 134 |
| 7 | nik_exists | 133 |
| 7 | DNR | 133 |
| 9 | AmShZ | 130 |
| 10 | Dominater069 | 129 |
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.