JavaScript | Height of Binary Tree

Calculate the height of binary tree
var maxDepth = function(root) {
if (root === null) return 0
return Math.max(maxDepth(root.left), maxDepth(root.right)) + 1
};

--

--

--

Working in Walmart as UI Developer | Mentor | React | JavaScript | HTML | CSS

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

Recommended from Medium

Know React onClick Event Handling with examples

How to push react code to Github in simple way

Uploading files/images to MongoDB using GridFS

Building A Node.js — Express App (covid19-updates)|Part-4

This Week In React #90

Removing Test Complexity

Top Features Of Angular 13 You Must Know

Local Node.js & JavaScript Keyboard Logger Server & Data Visualization

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
iAmSonika | www.startlearncoding.com

iAmSonika | www.startlearncoding.com

Working in Walmart as UI Developer | Mentor | React | JavaScript | HTML | CSS

More from Medium

JS | Count vowel from a String

How JavaScript Work and Execution Context?

Object in JavaScript

JavaScript Closure, Arrow Function, Callbacks, Promises, async/await