Why unordered_map Can Cause TLE in C++

Revision en2, by ankit_201, 2025-07-28 00:19:29

unordered_map offers average O(1) time for insert, find, and erase ,it can still cause Time Limit Exceeded (TLE)

1. Worst-Case Complexity is O(n)

Hash collisions can degrade performance from O(1) to O(n), especially with poor key distribution.

Use map (O(log n)) for consistent performance.

Add your knowlesge ..

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English ankit_201 2025-07-28 00:19:29 207 (published)
en1 English ankit_201 2025-07-28 00:09:59 319 Initial revision (saved to drafts)