Search⌘ K
AI Features

Solution: Number of Spaces Cleaning Robot Cleaned

Explore how to model a cleaning robot moving through a 2D binary matrix, cleaning unique spaces by tracking directionally visited states using bitwise operations. Understand how to simulate movement, rotation, and stopping criteria efficiently without extra memory. This lesson helps you build an algorithm to count all unique cleaned tiles in a room, applying matrix traversal and state encoding techniques.

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 ...