— From a string like "abcdef", if I use count (), then what will be the complexity O (1) or O (n)??
— There's not a function called count()
— So its complexity may depends on how you implement your count()
function, and the algorithm you use
— They are called «implementations» and they were build because people can and want 🤷🏻♂️
the «default» one is cpython
Message permanent page
— Str = input ()
Index = Str.count ('b')
What's the complexity for this code?
— For time complexity it is o(1) i guess.. i am not sure
— Https://github.com/python/cpython/blob/master/Objects/unicodeobject.c#L9493
you can analyze it yourself
Message permanent page