Shortest Path Problem Leetcode Solutions Python