diff --git a/src/main/java/com/github/pedrovgs/problem81/RotateRightString.java b/src/main/java/com/github/pedrovgs/problem81/RotateRightString.java new file mode 100644 index 00000000..729394cc --- /dev/null +++ b/src/main/java/com/github/pedrovgs/problem81/RotateRightString.java @@ -0,0 +1,13 @@ +package com.github.pedrovgs.problem81; + +import java.util.Arrays; + +public class RotateRightString { + public static String rotateLeft(String str, int d){ + char[] result = new char[str.length()]; + char[] data = str.toCharArray(); + for (int i = 0; i < data.length; i++) + result[(i+(data.length-d)) % data.length ] = data[i]; + return Arrays.toString(result); + } +}