Shortest Path Leetcode Problems Javascript Snake