Day #8: Number Of Unival Trees Using Python

I am a Software Engineer from Hyderabad. Here to learn and share what I learn.
Search for a command to run...

I am a Software Engineer from Hyderabad. Here to learn and share what I learn.
No comments yet. Be the first to comment.
Hi! I'm Manish. I was wondering what to do in this COVID-19 pandemic, to stay a bit productive and then the phrase 100 Days Of Code striked me while surfing the internet and I decided to take up the challenge. To begin with that, I have enolled for ...
Unveil Your Brilliance with DIY Portfolio โ Your Personalized Showcase, One File Edit Away!

Building a backend server application using Node.js, Express and JDoodle API to execute scripts and return the output as response.

Learning how to create mind maps to understand what's needed for the project and setting up the project folder with required dependencies quickly.

A series of articles on how to build a simple web app which serves an online IDE using the MERN stack to run code in multiple languages.

Hello everyone. Today is the Day 8 of the #100DaysOfCodeChallenge. Received a problem previously asked by Google with an easy tag to it.
A unival tree (which stands for "universal value") is a tree where all nodes under it have the same value.
Given the root to a binary tree, count the number of unival subtrees.
For example, the following tree has 5 unival subtrees:
0
/ \
1 0
/ \
1 0
/ \
1 1
Output
No. of unival subtrees= 5
To understand the recursion behind this code, please click here
Feel free to reach out for any query clearance.
Thanks and cheers:)