Untitled
unknown
java
a year ago
1.2 kB
11
Indexable
import java.util.*; public class Solution { public int[] getRotatedArray(int[] A, int rotations) { int size = A.length; rotations = rotations % size; int pivot = rotations; int[] newArr = new int[A.length]; int x = 0, counter = pivot; while (counter != size) { newArr[x] = A[counter]; counter++; x++; } counter = 0; while (counter != pivot) { newArr[x] = A[counter]; counter++; x++; } return newArr; } public int[][] multipleLeftRotation(int[] A, int[] B) { //You Can Code Here List<int[]> result = new ArrayList<>(); for (int i = 0; i < B.length; i++) { result.add(getRotatedArray(A, B[i])); } int[][] resultArr = new int[B.length][A.length]; for (int i = 0; i < result.size(); i++) { for (int j = 0; j < result.get(i).length; j++) { resultArr[i][j] = result.get(i)[j]; } } return resultArr; } }
Editor is loading...
Leave a Comment