Back to course home
0% completed
Vote For New Content
Why is space complexity O(n)?
Saman Ehsan
Jan 3, 2024
According to the explanation, as the input string grows, the size of the hashmap will be at most the number of unique characters in the alphabet being used. So wouldn't that be O(1) space because the size of the hashmap does not grow linearly as the input scales?
0
0
Comments
Comments
D
davemednikov 2 years ago
I didn't understand the explanation either. The "First Non-Repeating Character" problem's space complexity was O(1). I suppose the difference is in this one, it wasn't specified that the string could only contain letters? Either way, there is a finite number of possible...
Shubham Voraa year ago
Hey, space complexity is fixed!
On this page