Description
Submission
Rotating 90 degrees clockwise is the same as transposing then matrix and then reversing each row.
class Solution { public: void rotate(vector<vector<int>>& matrix) { for(int i = 0; i < matrix.size(); ++i) { for(int j = i + 1; j < matrix.size(); ++j) { swap(matrix[i][j], matrix[j][i]); } } for(int i = 0; i < matrix.size(); ++i) { reverse(matrix[i].begin(), matrix[i].end()); } } };