Shortest Path Algorithm Leetcode