helloShen / leetcode-helper

Save your time from building scaffolding for each leetcode problem.
345 stars 43 forks source link

TreeNode.bfs() #10

Open tianxie opened 4 years ago

tianxie commented 4 years ago

https://github.com/helloShen/leetcode-helper/blob/56bc2efee89405e1270bce8174e127fa2eef040a/src/main/java/com/ciaoshen/leetcode/util/TreeNode.java#L84-L85

For cases like:

    1
   / \
null  2

I think the above two lines should be:

if (n != null) {
    res.add(line);
    break;
}