forked from Kashmiri-cmd/Competitive-Coding
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathROTATE-IMAGE.cpp
More file actions
34 lines (34 loc) · 735 Bytes
/
ROTATE-IMAGE.cpp
File metadata and controls
34 lines (34 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// https://leetcode.com/problems/rotate-image/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
void rotate(vector<vector<int>> &matrix)
{
vector<vector<int>> copy = matrix;
int r = matrix.size();
int c = matrix[0].size();
for (int i = 0; i < r; i++)
{
for (int j = 0; j < c; j++)
{
matrix[i][j] = copy[c - 1 - j][i];
}
}
for (auto it : matrix)
{
for (auto iit : it)
{
cout << iit << " ";
}
cout << endl;
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL), cout.tie(NULL);
vector<vector<int>> v = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
rotate(v);
return 0;
}