Posts

Showing posts from September 7, 2021

Corona Spread Days

Image
Corona Spread Days  PROBLEM STATEMENT : There are N chairs in a line. The program must accept N integer values denoting the seating details in these N chairs.  - 1 represents a healthy person sitting in a chair.  - 0 represents the chair is empty.  - 2 represents the chair being occupied by a Coronavirus-infected person.  Each Corona virus-infected person will affect the healthy persons sitting adjacent to him/her so that the next day those affected will, in turn, start infecting their healthy adjacent persons. The program must print the number of days D required for the virus to stop spreading and the number of persons H who remain not infected by the virus in the end.  Boundary Condition(s):   2 <= N <= 20  Input Format:  The first line contains N.  The second line contains the N integer values separated by a space.  Output Format:  The first line contains D and H separated by a space.  Example Input/Outp...