Leetcode Problem 2728. Count Houses in a Circular Street

2728. Count Houses in a Circular Street

Leetcode Solutions

Using Door Status as Markers

  1. Close all doors by iterating up to k times, moving in one direction (e.g., left) and closing any open doors.
  2. Open one door to mark the starting house.
  3. Move in the same direction and count the number of houses until the open door is encountered again.
  4. Return the count as the number of houses on the street.
UML Thumbnail

Sequential Door Toggling

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...