Amazon interview question

Leetcode 130 Surrounded regions graph problem