Created
January 21, 2018 15:05
-
-
Save s4553711/3684c0a280101bfa01415baee2ff8bde 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
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