Rotate Matrix Time : Space : 12345678910111213141516void helper(vector<vector<int>>& A, int l, int r) { if(l >= r) return; vector<int> row; for(int i = l; i <= r; i++) row.push_back(A[l][i]); for(int i = l, j = r; i <= r; i++,j--) A[l][j] = A[i][l]; for(int i = l; i <= r; i++) A[i][l] = A[r][i]; for(int i = l, j = r; i <= r; i++,j--) A[r][i] = A[j][r]; for(int i = l; i <= r; i++) A[i][r] = row[i-l]; helper(A,l+1,r-1);}void Solution::rotate(vector<vector<int> > &A) { helper(A,0,A.size() - 1);}