Skip to content

Instantly share code, notes, and snippets.

@s4553711
Created January 21, 2018 15:05
Show Gist options
  • Save s4553711/3684c0a280101bfa01415baee2ff8bde to your computer and use it in GitHub Desktop.
Save s4553711/3684c0a280101bfa01415baee2ff8bde to your computer and use it in GitHub Desktop.
class Solution {
public:
void rotate(vector<vector<int>>& matrix) {
int n = matrix.size();
for(int i = 0; i < n; i++) {
for(int j = 0; j < i; j++)
swap(matrix[i][j], matrix[j][i]);
}
for(int i = 0; i < n; i++)
reverse(matrix[i].begin(), matrix[i].end());
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment