Back to course home
0% completed
Vote For New Content
The argument for O(1) space
chidi.nwaka
Oct 29, 2024
Since our two input strings s and t are only to be comprised of lowercase english letters, this sets the maximum number of unique letters we could encounter to be 26, regardless of string size. Because of this, our mapping of letters to counts is never going to contain more than 26 active keys at any moment. Thus, our space complexity is bounded to O(26) = O(1).
However, the space demand does not grow reliably as a function of the string input size, meaning it is not O(N) space.
3
0
Comments
Comments