Search⌘ K
AI Features

Solution: Number of Spaces Cleaning Robot Cleaned

Explore how a cleaning robot moves through a binary 2D matrix starting at the top-left corner, turning when encountering obstacles, and cleaning each unique space. This lesson explains the in-place bitwise tracking method to mark visited cells by direction, enabling efficient detection of repeated states and termination of the cleaning loop, helping you understand how to simulate movement and state management in matrix problems.

Statement

You are given a 0-indexed 2D binary matrix, room, representing a room of size m×nm \times n. In this matrix, 00 represents an empty space, while 11 represents a space occupied by an object. The top-left corner of the room is always empty ...