Water Connection Problem Leetcode