Company: Tech Mahindra
Difficulty: medium
Cancellation Notification Problem Description James was going to throw a party, but he had to cancel because he has to attend an important meeting. He had invited N neighbors whose houses are in a straight line adjacent to his house. Some of his neighbors are cooperative while others are not. If a cooperative neighbor comes to know about the cancellation either directly or through any of the other cooperative neighbors then that neighbor can inform four additional neighbors at most: the two neighbors that live to his adjacent left and the two that live to his adjacent right. Conversely, if a non-cooperative neighbor learns about the cancellation, he will not communicate the message to anyone. Due to time restrictions, James can make only one call to inform only one neighbor about the party cancellation. However, he wants to maximize the number of neighbors who will be informed about the cancellation. For his own assurance, he decides to keep a record of who has been informed and who ha