Time complexity of this solution will be O(n2) right?
Time complexity
Pls correct me if I am wrong . But as far as I know in java map retrieves elements in O(1) time because go hash function
because *of hash function
…
i am talking about c++ ordered map.
in general this is the complexity->
O(n*n * acces time of map)
Oh… could you pls confirm that time complexity in java will beO(n2)
…
u should know about how hasmap work , O(1) is amortied time complexity of hashmap, in worst case it can go O(N) (rare)
so u can say time complexity will be roughly O(N^2) …but not always
I just wanted to confirm . I thought that we can verify questions of this type here.
No issues I will contact the support team .
…
verify what?
question and solution both are correct
the question I asked - time complexity one … not the problem statement
…
read my previous response i already answered it.
if it is not clear then pls study about how hashmap implemented , how distribution of data affect the complexity . what is load factor and how it related to access time.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.