1
class Solution:
2
def rotateTheBox(self, box: List[List[str]]) -> List[List[str]]:
3
# move stones to right, row by row
4
for i in range(len(box)):
5
stone = 0
6
for j in range(len(box[0])):
7
if box[i][j] == "#": # if a stone
8
stone += 1
9
box[i][j] = "."
10
elif box[i][j] == "*": # if a obstacle
11
for m in range(stone):
12
box[i][j - m - 1] = "#"
13
stone = 0
14
# if reaches the end of j, but still have stone
15
if stone != 0:
16
for m in range(stone):
17
box[i][j - m] = "#"
18

19
# rotate box, same as leetcode #48
20
box[:] = zip(*box[::-1])
21

22
return box

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0