String membership check in hash set time complexity

Given a string s and a hashset of strings words, what is the time complexity of the operation: s in words? Assume all strings have length M. My current guess is O(M) to compute the hash of s, O(1) to find that bucket in the hash table, and O(M*number of strings in the bucket) to compare the strings in the bucket and the s , so a total of O(M*number of strings in the bucket). Not assuming any fancy string comparison algorithms here--want to focus more on the other parts.

Comments (1)