Skip to content

Instantly share code, notes, and snippets.

@webdevwilson
Created October 7, 2022 01:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webdevwilson/b7b304f8fc4c28e3740d85aa00656334 to your computer and use it in GitHub Desktop.
Save webdevwilson/b7b304f8fc4c28e3740d85aa00656334 to your computer and use it in GitHub Desktop.
public class TestString {
public static void main(String... args) {
final String word = "timecomplexityn";
System.out.println(word);
final String space = " ".repeat(word.length()-2);
for(int i = 1; i < word.length() - 1; i++) {
System.out.print(word.charAt(i) + space + word.charAt(word.length() - i) + "\n");
}
System.out.println(new StringBuilder(word).reverse());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment