Question about the time complexity when hashing long direction/offset strings

  • 0

    It is true that generally, inserting into a hash set is O(1). However, in many of these solutions, people make long strings with the directions that they traversed the islands in or the coordinates with an offset, and then they put these strings in a hashset. Surely computing the hash code for such long strings is not really O(1), right? When we analyze the time complexity for this question, are we still allowed to assume O(1) given that the hashed strings can be so long?

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.