Breadth First Search Algorithm Leetcode