Person in room - search strategy
Anonymous User
364

You are given an array representing rooms. You can only open 1 room per day. The person moves from 1 room to another (either 1 left or 1 right) over-night. If on the edge, the person moves in one possible direction.

Given the room and a strategy, find whether the strategy is valid in finding the person on any given day.

Input:
3 rooms [0] [1] [2]. Strategy {1, 1} (room 1 is open on day 1, room 1 is again opened on day 2).
Output:
True

Strategy {1, 0}
Output: False

Input:
5 rooms [0..4], Strategy {1,2,3,1,2,3}.
Output: True.

Comments (2)