2753. Count Houses in a Circular Street II
You are given an object
street
of classStreet``k
which represents a maximum bound for the number of houses in that street (in other words, the number of houses is less than or equal tok
). Houses’ doors could be open or closed initially (at least one is open).Initially, you are standing in front of a door to a house on this street. Your task is to count the number of houses in the street.
The class
Street
contains the following functions which may help you:
void closeDoor()
: Close the door of the house you are in front of.boolean isDoorOpen()
: Returnstrue
if the door of the current house is open andfalse
otherwise.void moveRight()
: Move to the right house.
1
ton
, then the right house ofhousei
ishousei+1
fori < n
, and the right house ofhousen
ishouse1
.Return
ans
which represents the number of houses on this street.
1 | /** |