Amazon interview question

LC hard problem with matrix/graphs