I have a doubt regarding the space complexity of a program. Let's say I am iterating over an Array (stores event ids) with a size of n (may be in billions). I wanted to track the occurrence of each event id, so I have used a hash map to store event id as key and its occurrence counter as value.
Here is the pseudo code:
Map m = HashMap<>
for i to n-1
if m.contains(i)
int prevCount = m.get(i)
m.put(i, prevCount +1)
else
m.put(i, 1)
What would be the space complexity?
PS This is my first question in stackoverflow, if it seems duplicate, please route me to the correct answer.