Edit: My bad, I misread!
s is not a string, but an array
Replacing the a character in a string, is not O(n) because of immutability and the need to create a new string each time?
Edit: My bad, I misread!
s is not a string, but an array
Replacing the a character in a string, is not O(n) because of immutability and the need to create a new string each time?
I think the string immutability is depending on the programming language you use, and in this book we don’t depending on that for text.