TLE while using unordered_map<> but AC when using mp.find() function

Revision en1, by Tenz1n, 2023-09-16 09:02:49

I was solving the problem : 1732D1 - Balance (Easy version). And my solution was same as i keep the track of the kth-MEX of the xth element when ever the request has been made. So for checking whether the kth element is present in the set or not, i used unordered_map<> by while adding the elements in the unordered_map<> when the add operation is processed. But i got TLE at test 36. Later when i checked other's solution they used ordered_map<> and used the .find() function to check whether the element is added to the set or not. And then i also used that .find() function and it got accepted.

Can anyone help tell me why by using mapping with unordered_map<> gives TLE and get Accepted while using .find() function?

Submission 1 : 223430749 Submission 2 : 223513656

Tags mapping

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Tenz1n 2023-09-16 09:02:49 886 Initial revision (published)