Shortest Path Algorithm Leetcode 150