Shortest Path Algorithm Leetcode Two Sum Solution Javascript W3schools