79273434

Date: 2024-12-11 23:24:09
Score: 1
Natty:
Report link

As you said, the hash map is gonna have at its most 26 entries/characters, with each one holding an integer that might ocupy 4 to 8 bytes - 4 bytes makes already possible to reach: 2,147,483,647 as an integer.

Thinking about that, it doesn't matter how long your string argument (p) is, the entries are gonna still be capped to the 26 characters of the hash map and the space ocuppied (4 to 8 bytes) are never gonna change. Therefore, the space complexity does not grow with the p size, meaning it's not linear but constant -> O(1).

:)

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: Leonardo Rafaelli