DEV Community

Discussion on: Path Sum

Collapse
 
miniscruff profile image
miniscruff • Edited

It probably won't help much but before you append to the queue you can check if the node.val >= sum and skip the append. Would only apply if our node values where always >= 0 though.

Collapse
 
shoryu profile image
Shoryu

That's a very good way to work effectively. Thanks a lot.