Swayam78's blog

By Swayam78, history, 11 hours ago, In English
  • Vote: I like it
  • -7
  • Vote: I do not like it

»
11 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

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 :)

  • »
    »
    10 hours ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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.

    • »
      »
      »
      10 hours ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      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.

      • »
        »
        »
        »
        10 hours ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Oh .. I get It , Thanks.

  • »
    »
    9 hours ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Thank you Bhai , I checked 2*n solution worked.