2753. Count Houses in a Circular Street II
You are given an object
streetof classStreet``kwhich 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
Streetcontains the following functions which may help you:
void closeDoor(): Close the door of the house you are in front of.boolean isDoorOpen(): Returnstrueif the door of the current house is open andfalseotherwise.void moveRight(): Move to the right house.
1ton, then the right house ofhouseiishousei+1fori < n, and the right house ofhousenishouse1.Return
answhich represents the number of houses on this street.
1 | /** |