(If you're interested, here's some more JS-golfed solutions.)
This seems to happen a lot...
Obviously quite simple.
Don't know the time complexity of String.prototype.replace, but I'm assuming it's O(1) time. Correct me if I'm wrong.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.