Given a binary tree of N nodes, where every node value is a number. Find the sum of all the numbers which are formed from root to leaf paths.
- Time : O(n)
- Space : O(d)
1 | void helper(Node* node, long long path, long long& res) { |
Given a binary tree of N nodes, where every node value is a number. Find the sum of all the numbers which are formed from root to leaf paths.
1 | void helper(Node* node, long long path, long long& res) { |