Skip to content

mistergamarra/interview-question-server-updates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Interview Question:

Introduction:

There is a Matrix that hold servers, one server have an state, active equals to 1 or inactive equals to 0. In one day a server in state 1 can update the neighbors servers in the matrix, however the adyancents servers have its state set to one at the next day.

Question :

The question is How many days take update all servers in the matrix?. If :

Inputs:

columns = 5``

rows = 5

M = [{0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 1, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}]

for the day 1 the matrix becomes:

M = [{0, 0, 0, 0, 0}, {1, 1, 1, 0, 0}, {1, 1, 1, 0, 0}, {1, 1, 1, 0, 0}, {0, 0, 0, 0, 0}]

for the day 2 the matrix becomes:

M = [{1, 1, 1, 1, 0}, {1, 1, 1, 1, 0}, {1, 1, 1, 1, 0}, {1, 1, 1, 1, 0}, {1, 1, 1, 1, 0}]

for the day 3 the matrix becomes:

M = [{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}]

About

Question interview about arrays and neighbors

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages