leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
1861.cpp (753B)
0 #pragma GCC optimize(fast); 1 static auto _ = []() { 2 std::ios_base::sync_with_stdio(0); 3 std::cin.tie(0); 4 return 0; 5 }(); 6 7 class Solution { 8 public: 9 vector<vector<char>> rotateTheBox(const vector<vector<char>> &box) const { 10 const int n = box.size(), m = box[0].size(); 11 vector<vector<char>> res(m, vector(n, '.')); 12 13 for (int i = 0; i < n; i++) { 14 for (int j = m - 1, limit = m; j >= 0; j--) { 15 if (box[i][j] == '.') continue; 16 if (box[i][j] == '*') { 17 res[j][n - i - 1] = '*'; 18 limit = j; 19 continue; 20 } 21 res[--limit][n - i - 1] = '#'; 22 } 23 } 24 25 return res; 26 } 27 };