O(nm) | Simple two pointers | No extra space for processing
Intuition\n Describe your first thoughts on how to solve this problem. \n90 degree Rotation:\n- When we rotate array by 90 degrees, final[j][i] will be box[n - 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n**90 degree Rotation:**\n- When we rotate array by 90 degrees, final[j][i] will be box[n - i - 1][j] i.e. rows will become columns. \n- After rotation, stones will move drop downwards -> moves in the columns which is equivalent of moving in row from left to right in the initial matrix. \n\n\nSo we have to implement simple logic for movement of stones in the same row, keeping in mind that obstacle don\'t move and after that we transpose the matrix. \n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nWe can process each row individually, independent from each other. \nWe can achieve this using two pointer menthod.\n- r -> will keep track of the position where the next stone can drop. \n- l -> will keep track of the current stone. \n\nStart moving from end, and move r to the next available position. Then start moving l pointer to find the next available stone and put the stone at rth position. We can perform swap() operation between l and r as after stone drops to r, l will become empty. \nThe only thing to note is while moving l pointer if we encounter any obstacle, then we have to update r as stone cannot go pass obstacle at any cost. \n\n# Complexity\n- Time complexity: O(NM)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(NM)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    vector<vector<char>> rotateTheBox(vector<vector<char>>& box) {\n        int n = box.size(); \n        int m = box[0].size(); \n        for (int i = 0; i < n; i++) {\n            int r = m - 1;\n            int l = m - 1; \n            while (l >= 0) {\n                while (r > l && (box[i][r] != \'.\')) {\n                    r--; \n                }\n                if (box[i][l] == \'*\') {\n                    r = l; \n                } else if (box[i][l] == \'#\') {\n                    swap(box[i][l], box[i][r]); \n                }\n                l--; \n            }\n        }\n        vector<vector<char>> ans(m, vector<char> (n)); \n        for (int i = 0; i < n; i++) {\n            for (int j = 0; j < m; j++) {\n                ans[j][i] = box[n - i - 1][j]; \n            }\n        }\n        return ans; \n    }\n};\n```
['Two Pointers', 'C++']