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

Defer keyword in Swift

It is almost done …. but

“My” Cloud Resume Challenge

Introduction to checkstyle

Releasing a React Native application

Linux room 1

Uploading Files to Google Cloud Storage using a Flask API (2 of 3)

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

Find Median Of Two Sorted Arrays — LeetCode Solutions

Connect Ropes(code and explanation)

Leetcode 142. Linked List Cycle II

Sorting Algorithms Explained Using Python: Radix Sort

Glass Cube and Dots