Algorithm · Capital One · Medium
Requirements You receive the root node of a binary tree, where every node exposes val, left, and right. Produce a list containing every path that starts at the root and ends at a leaf. Represent each path as the node values encountered from top to bottom. Special cases: when the tree has no nodes, return []; when it consists only of its root, return [[root.val]]. Examples The first result follows the route from 4 through 7 to leaf 8, while the second goes directly from 4 to…
Checking your access…