Shortest Path Algorithm Leetcode Two Sum 2