File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ class Solution {
2+ public:
3+ void swapChar(vector<char> &vec)
4+ {
5+ int n = vec.size(), Hash = 0;
6+ unordered_map<int, int>store;
7+ for(int i = 0; i < n; i++)
8+ {
9+ Hash += vec[i] == '#';
10+ if(vec[i] == '*')
11+ store[i] = Hash, Hash = 0;
12+ }
13+ if(Hash) store[n] = Hash;
14+
15+ for(auto [idx_i, count] : store)
16+ {
17+ int idx = idx_i;
18+ while(count--) vec[--idx] = '#';
19+ while(idx-- and vec[idx] != '*') vec[idx] = '.';
20+ }
21+ }
22+
23+ vector<vector<char>> rotateTheBox(vector<vector<char>>& box)
24+ {
25+ int n = box.size(), m = box[0].size();
26+ for(auto &Box:box) swapChar(Box);
27+
28+ vector<vector<char>>box90;
29+ for(int i = m - 1; i >= 0; i--)
30+ {
31+ vector<char>temp;
32+ for(int j = n - 1; j >= 0; j--)
33+ temp.push_back(box[j][i]);
34+ box90.push_back(temp);
35+ }
36+
37+ reverse(begin(box90), end(box90));
38+ return box90;
39+ }
40+ };
You can’t perform that action at this time.
0 commit comments