Shortest Path Problem Leetcode Python Questions