Pergunta de entrevista da empresa Mobility Quest

Matrix problem which is much confusing