_destiny's blog

By _destiny, history, 4 years ago, In English

Can I say my solution is in O(1) space if I use a hash array of fixed size say of size 52(for lowercase and uppercase alphabets) to count the number of each alphabet that is present in a string?

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

If you assume that the alphabet size is constant, then the space requirement is O(1). However, if a general case for any alphabet is considered, then it is O(m) where m is the number of characters.