Sum of Root to Leaf Paths

  • We will be starting at the root with current number curr = 0.
  • Every time when the current node’s digit appended to curr from root to leaf and we will be recursing to left and right child.
  • When we reach the leaf node (a node that doesn’t have any left or right child), we will be forming complete root-to-leaf number. Then we will add Curr to overall Number.

--

--

--

I write about Python, Algorithmic Trading, Quantitative Finance, and our Mind and Universe.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

A Concise Intro to Computer Algorithms: Python Complete Course — Part 2

A dummy image for better reading and navigation.

Making a social media shareable link with c# .Net

How to convert Markdown MD to HTML format in Python

[note]Some sample code of python#2

Ecommerce Script That Is Built With Fantastic Features

ecommerce script

A Glance At Conditional Conformance

SPICE (Software Process Improvement and Capability Determination) in software engineering

How to setup Google Cloud Scheduler job triggering your Cloud Function

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Balaji MJ

Balaji MJ

I write about Python, Algorithmic Trading, Quantitative Finance, and our Mind and Universe.

More from Medium

Cracking the Coding Interview Book Problem Series: Problem 7

Leetcode — Isomorphic Strings — Easy

k-ary tree in MySQL

Data Structures questions you might get asked on your interview