let str = "hello world"; str = "n"; console.log(str); // hello world
under strict mode, this throws an error because you cannot modify strings (read only).
How would you implement an O(1) time, O(1) space algorithm in js to do
str[index] = char? In C, this is trivial because access is O(1) and you can modify that element without having to allocate a new array and copy values over.
I have found solutions using split to do this … but isnt this overkill? That means O(n) time and space.