Блог пользователя _destiny

Автор _destiny, история, 6 лет назад, По-английски

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?

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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.