Skip to content

Instantly share code, notes, and snippets.

@vikitripathi
Created November 9, 2014 10:03
Show Gist options
  • Save vikitripathi/bd8fc7080fb58875b7e3 to your computer and use it in GitHub Desktop.
Save vikitripathi/bd8fc7080fb58875b7e3 to your computer and use it in GitHub Desktop.
public static String reverseRecursively(String str) {
//base case to handle one char string and empty string
if (str.length() < 2) {
return str;
}
return reverseRecursively(str.substring(1)) + str.charAt(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment