Delete comment from: Java67
phil said...
My mistake! The original article states that the algorithm is O(1) because it (wrongly) says it only uses 2 new variables regards of size of the string. Because two new arrays of the same size of the string are created the space needed will be either 3N or 2N, depending on whether or not you include the original string. Either way, the space complexity is O(n). That is, the space needed grows linearly with the size of the string.
Jun 3, 2019, 1:26:49 PM
Posted to [Solved] How to reverse a String in place in Java? Example