Leetcode Breadth First Search Algorithm Problem