I have a 3x4 array that I want to rotate left once, so that it becomes a 4x3. Imagine a box of values, and just rotate that box left. Here's the function I wrote:
public static int[][] rotLeft(int[][] source) {
int[][] newImage=new int[source[0].length][source.length];
for (int i=0;i<source.length;i++)
for (int j=0;j<source[0].length;j++)
newImage[source.length-j][i]=source[i][j];
return newImage;
}
This code should be working, as it passes my handwritten test (when I run it on paper), but when I try to run it through the grader that my teacher wrote, it fails the test. Whats wrong with this code?