In this submission -> [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 -> [submission:306878312]↵
↵
~~~~~↵
map<ll,ll> freq;↵
~~~~~↵
↵
Problem Link -> [problem:1775b]↵
↵
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 -> [problem:1775b]↵
↵
↵
↵
[BTW This is my first blog so please forgive me if I made any mistake.]↵
↵
↵
↵
↵
↵
~~~~~↵
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 -> [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 -> [problem:1775b]↵
↵
↵
↵
[BTW This is my first blog so please forgive me if I made any mistake.]↵
↵
↵
↵
↵