Leetcode Breadth First Search Algorithm Javascript Format Number