Minimum Spanning Tree Leetcode Practice Java