Created
April 21, 2021 04:00
-
-
Save rohanjai777/2b7a685ced472e2cd437bb9b19589b3a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void rotate(ArrayList<ArrayList<Integer>> arr) { | |
int n = arr.size(); | |
int m = arr.get(0).size(); | |
for(int i=0;i<n;i++){ | |
for(int j=i;j<m;j++){ | |
int temp = arr.get(i).get(j); | |
arr.get(i).set(j,arr.get(j).get(i)); | |
arr.get(j).set(i,temp); | |
} | |
} | |
//System.out.println(arr); | |
for(int i=0;i<n;i++){ | |
reverse(arr.get(i)); | |
} | |
} | |
public void reverse(ArrayList<Integer> al){ | |
Collections.reverse(al); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment