Breadth First Search Algorithm Leetcode Javascript Questions