Easy solution with taking transpose of matrix


#1

Comment body goes here.
void Solution::rotate(vector<vector > &A) {
// Do not write main() function.
// Do not read input, instead use the arguments to the function.
// Do not print the output, instead return values as specified
// Still have a doubt. Checkout www.interviewbit.com/pages/sample_codes/ for more details
int i,j,n,m,x,y,z;
n=A.size();
m=A[0].size();
for(i=0;i<n;i++){
for(j=0;j<i;j++){
swap(A[i][j],A[j][i]);
}
}
for(i=0;i<n;i++){
reverse(A[i].begin(),A[i].end());
}
return ;

}


#2

just take transpose of matrix and after that reverse all row of given matrix and we will get our answer