Skip to content

Instantly share code, notes, and snippets.

@Se7soz
Last active April 25, 2017 18:24
Show Gist options
  • Select an option

  • Save Se7soz/8414279 to your computer and use it in GitHub Desktop.

Select an option

Save Se7soz/8414279 to your computer and use it in GitHub Desktop.
Read the How to prepare for an interview series at my blog: http://se7so.blogspot.com/2014/01/how-to-prepare-for-interview.html
void rotate90(vector<vector<int> >& image) {
int n = image.size();
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
swap(image[i][j], image[n-j-1][n-i-1]);
}
}
for(int i = 0; i < n/2; i++) {
for(int j = 0; j < n; j++) {
swap(image[i][j], image[n-i-1][j]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment