-
Notifications
You must be signed in to change notification settings - Fork 0
/
1861.cpp
30 lines (29 loc) · 834 Bytes
/
1861.cpp
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
#include<bits/stdc++.h>
using namespace std;
class Solution {
public:
vector<vector<char>> rotateTheBox(vector<vector<char>>& box) {
int n = box.size(), m = box[0].size();
for (int i = 0; i < box.size(); ++i) {
int next = m - 1;
for (int j = m - 1; j >= 0; --j) {
if (box[i][j] == '*') {
next = j - 1;
} else if (box[i][j] == '#') {
swap(box[i][j], box[i][next]);
next--;
}
}
}
vector<vector<char>> newMatrix(m, vector<char>(n));
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
newMatrix[j][n - i - 1] = box[i][j];
}
}
return newMatrix;
}
};
int main(){
return 0;
}