Arrays And Hashing Leetcode Problems Javascript Snake