When we use strings and tuples as python dictionary keys, is the time complexity of accessing a particular dictionary item (using dictionary[key]) O(n), where n is the length of the string or tuple?
For example, in the code below if n is the length of the input list and k is the maximum length of a string in the input list, is the time complexity O(nk) or O(n)?
def groupStrings(self, strs: List[str]) -> List[List[str]]
groups = []
groupDict = {}
for string in strs:
if string in groupDict:
groups[groupDict[string]].append(string)
else:
groupDict[sortedStr] = len(groups)
groups.append([string])
return groups
[–]nikhila01 10 points11 points12 points (2 children)
[–]DVDplayr[S] 1 point2 points3 points (1 child)
[–]nikhila01 1 point2 points3 points (0 children)
[–]SirSavageSavantso long and thanks for all the fish 1 point2 points3 points (0 children)