Rotate a 2d matrix to the right
- by adam
I want a 2d matrix to rotate to the right, it compiles fine but when I try to the run it freezes. For example I want {{10,20,30},{40,50,60}} to rotate into {{40,10},{50,20},{60,30}}
import java.util.*;
public class Rotate{
public static int[][] rotate(int[][] m) {
int [][] rotateM = new int[m[0].length][m.length];
for (int i= 0; i<…