Single Source Shortest Path Leetcode Javascript