alphaaditya's blog

By alphaaditya, history, 11 hours ago, In English

In this submission -> 306874451 as you go through the solve function you will see that I have used

vector<ll> freq(2e5+1,0);

as you can see it got Time Limit exceeded on test case 2, after replacing the vector with map in the following submission -> 306878312

map<ll,ll> freq;

It got accepted, now according to my knowledge map takes O(log N) time to access its elements while vector takes O(1) time.

So in the worst case scenario shouldn't the vector be better ?

Problem Link -> 1775B - Gardener and the Array

[BTW This is my first blog so please forgive me if I made any mistake.]

Full text and comments »

  • Vote: I like it
  • +2
  • Vote: I do not like it