Is there any facility in the standard Java libraries that, given a CharSequence, produces the reverse in O(1) time?
I guess this is \"easy\" to implement, just wond
Here I have a sample of the same using substring method and o(n). I am aware that using substring will hold complete string memory.
for(int i = 0; i < s.length(); i++) {
s = s.substring(1, s.length() - i) + s.charAt(0) + s.substring(s.length() - i);
System.out.println(s);
}
This might help you. Tell me if I am wrong!!