Breadth First Search Algorithm Leetcode 150