mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-07 09:45:04 +08:00
Add tests for merge sort (#3715)
This commit is contained in:
@ -0,0 +1,20 @@
|
||||
package com.thealgorithms.strings;
|
||||
|
||||
/**
|
||||
* Reverse String using Recursion
|
||||
*/
|
||||
|
||||
public class ReverseStringRecursive {
|
||||
/**
|
||||
* @param str string to be reversed
|
||||
* @return reversed string
|
||||
*/
|
||||
public static String reverse(String str)
|
||||
{
|
||||
if(str.isEmpty()){
|
||||
return str;
|
||||
} else {
|
||||
return reverse(str.substring(1))+str.charAt(0);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user