Algorithm · Meta · Medium
Given the root of a binary tree, every node stores a single digit. For each root-to-leaf path, concatenate the node digits in order to form a decimal integer. Your task is to return the sum of those integers for all root-to-leaf paths. Implement the solution as sumRootToLeaf(root), taking the tree's root as its only argument. A leaf is a node that has neither a left nor a right child. A single-node tree therefore has one root-to-leaf path. Examples Example 1 Example 2…
Checking your access…