Sonatus Interview Question

Variation of leetcode connected islands, but slightly more difficult.