8000 * Done with "1861. Rotating the Box". · garciparedes/leetcode@b5ec657 · GitHub
[go: up one dir, main page]

Skip to content

Commit b5ec657

Browse files
committed
* Done with "1861. Rotating the Box".
1 parent 9050e4d commit b5ec657

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

problems/1861_rotate_the_box.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Solution:
2+
def rotateTheBox(self, box: List[List[str]]) -> List[List[str]]:
3+
ans = list()
4+
for j in range(len(box[0])):
5+
row = list()
6+
for i in reversed(range(len(box))):
7+
row.append(box[i][j])
8+
ans.append(row)
9+
10+
for j in range(len(ans[0])):
11+
displaced = True
12+
while displaced:
13+
displaced = False
14+
for i in reversed(range(1, len(ans))):
15+
if ans[i][j] == '.' and ans[i - 1][j] == '#':
16+
ans[i][j] = '#'
17+
ans[i - 1][j] = '.'
18+
displaced = True
19+
20+
return ans

0 commit comments

Comments
 (0)
0