1861. Rotating the Box Medium

@problem@discussion
#Array#Two Pointers#Matrix



1/**
2 * [1861] Rotating the Box
3 *
4 * You are given an m x n matrix of characters box representing a side-view of a box. Each cell of the box is one of the following:
5 * 
6 * 
7 * 	A stone '#'
8 * 	A stationary obstacle '*'
9 * 	Empty '.'
10 * 
11 * 
12 * The box is rotated 90 degrees clockwise, causing some of the stones to fall due to gravity. Each stone falls down until it lands on an obstacle, another stone, or the bottom of the box. Gravity does not affect the obstacles' positions, and the inertia from the box's rotation does not affect the stones' horizontal positions.
13 * 
14 * It is guaranteed that each stone in box rests on an obstacle, another stone, or the bottom of the box.
15 * 
16 * Return an n x m matrix representing the box after the rotation described above.
17 * 
18 *  
19 * Example 1:
20 * 
21 * <img alt="" src="https://assets.leetcode.com/uploads/2021/04/08/rotatingtheboxleetcodewithstones.png" style="width: 300px; height: 150px;" />
22 * 
23 * 
24 * Input: box = [["#",".","#"]]
25 * Output: [["."],
26 *          ["#"],
27 *          ["#"]]
28 * 
29 * 
30 * Example 2:
31 * 
32 * <img alt="" src="https://assets.leetcode.com/uploads/2021/04/08/rotatingtheboxleetcode2withstones.png" style="width: 375px; height: 195px;" />
33 * 
34 * 
35 * Input: box = [["#",".","*","."],
36 *               ["#","#","*","."]]
37 * Output: [["#","."],
38 *          ["#","#"],
39 *          ["*","*"],
40 *          [".","."]]
41 * 
42 * 
43 * Example 3:
44 * 
45 * <img alt="" src="https://assets.leetcode.com/uploads/2021/04/08/rotatingtheboxleetcode3withstone.png" style="width: 400px; height: 218px;" />
46 * 
47 * 
48 * Input: box = [["#","#","*",".","*","."],
49 *               ["#","#","#","*",".","."],
50 *               ["#","#","#",".","#","."]]
51 * Output: [[".","#","#"],
52 *          [".","#","#"],
53 *          ["#","#","*"],
54 *          ["#","*","."],
55 *          ["#",".","*"],
56 *          ["#",".","."]]
57 * 
58 * 
59 *  
60 * Constraints:
61 * 
62 * 
63 * 	m == box.length
64 * 	n == box[i].length
65 * 	1 <= m, n <= 500
66 * 	box[i][j] is either '#', '*', or '.'.
67 * 
68 */
69pub struct Solution {}
70
71// problem: https://leetcode.com/problems/rotating-the-box/
72// discuss: https://leetcode.com/problems/rotating-the-box/discuss/?currentPage=1&orderBy=most_votes&query=
73
74// submission codes start here
75
76impl Solution {
77    pub fn rotate_the_box(box: Vec<Vec<char>>) -> Vec<Vec<char>> {
78        vec![]
79    }
80}
81
82// submission codes end
83
84#[cfg(test)]
85mod tests {
86    use super::*;
87
88    #[test]
89    fn test_1861() {
90    }
91}
92


Back
© 2025 bowen.ge All Rights Reserved.