Space complexity

In the video, they used vector to store the elements so the space complexity will be o(n)
but instead of that if we use map and store the count what’s the problem in that??

also the problem statement we use give ans in o(1) how it can be using vector of n size

@rkrrockstar89 yes but generally in interviews the interviewer dont consider the array size and all. its given (the constraints are only for the algo) . also using map more time will be used as operation takes nlogn

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.