You are given an m x n matrix of characters boxGrid representing a side-view of a box. Each cell of the box is one of the following: A stone '#' A stationary obstacle '*' Empty '.' 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. It is guaranteed that each stone in boxGrid rests on an obstacle, another stone, or the bottom of the box. Return an n x m matrix representing the box after the rotation described above.
CodingMid-level
Leetcode 1861. Rotating the Box
Rotate an m×n grid 90° clockwise and simulate gravity so each stone '#' falls until blocked by an obstacle '*' or another stone, returning the resulting n×m grid. The core challenge is compacting stones within obstacle-separated segments toward the gravity direction after rotation.
Contextos reais
Onde essa pergunta já apareceu
Use esses exemplos para entender em que contexto ela costuma cair e adaptar sua prática.
Snowflakemidago. de 2025
Anexos públicos
Materiais associados
Nenhum anexo público associado a esta pergunta.
Sinais de resposta forte
Você deixa claro por que escolheu essa abordagem e o que descartou.
Seu código vem acompanhado de testes mentais e edge cases relevantes.
Sua explicação ajuda o entrevistador a acompanhar o raciocínio em tempo real.
O que costuma enfraquecer a resposta
Entrar direto no código sem alinhar interpretação do problema.
Passar tempo demais em silêncio e só explicar no fim.
Ignorar complexidade, invariantes e estratégia de teste.
Continue a preparação com o banco completo
No app você encontra perguntas parecidas, compara empresas e aprofunda essa busca com mais filtros.