Shortest Path Problem Leetcode Solutions Java