This question for example: https://leetcode.com/problems/first-unique-character-in-a-string/solution/
In normal circumstances if we use a HashMap<Integer, Integer>, the space complexity should be O(n).
However in this question's discussion, I see people arguing the space complexity is O(26) ~ O(1) which I guess makes sense.
So I have two questions:
I understand the space complexity is O(1) if we use int[26]. But is it also O(1) if we use HashMap<Integer, Integer> given that we're only dealing with 26 characters of the alphabet? (basically, does it matter what data structure you use if input is constrained to 26 characters? would space complexity be O(1) regardless?)
At what point can the argument for O(1) space be invalid? If the question was expanded to include ASCII characters, we're looking at O(128) which is still ~ O(1). Now let's say we add another languge's alphabet and now we're dealing with 1000 characters. Is O(1000) still ~ O(1)? Is O(10000) ~ O(1)? At which point can we safely say that hey, this is no longer O(1) space but rather O(n)?