Problem-Click Here

Unordered Map Solution -Click Here (AC)

Map Solution - Click Here (TLE)

Worst Case Complexities:-

Unordered Map - O(n) [I know Best case is O(1) for unordered_map]

Map-O(Log n)

Even Complexities are saying that map should give AC.

Can Anyone Explain the reason Why is it Happening ?

Thanks In Advance!