manjuransari143
BAN USER
Repsandrafdenn, Associate at CareerCup
Je suis développeur web dans une société de Wild Oats Markets, j'adore faire du shopping et j'ai une ...
RepLisaTQuinn, Analyst at A9
I have a passion for reading and creative writing and attend many workshops and conventions surrounding love spell that work ...
Repmarygaustria, Analyst at ADP
I am Mary from Los Angeles, USA. I am working as a Manager in Fragrant Flower Lawn Services company. I ...
Repggeraldinejrivera, Aghori Mahakal Tantrik at ABC TECH SUPPORT
I am a fashion model, talented in runway turns and photoshoot prep. I Have worked at two displaying organizations and ...
Repanitajmiller3, Android test engineer at ADP
Je suis passionnée par le monde du marketing de marque. Je souhaite explorer Comment faire revenir l etre aimé avec ...
Replisapyara, abc at 247quickbookshelp
I am motivated and organized professional with proven years of experience in mail services and industry having vast experience as ...
RepI graduated from College with a master’s degree in arthrogryposis. After graduation I am working as a manager in ...
Repjudydschultz1234, Android test engineer at Eterno Infotech Pvt Ltd
Spent a weekend researching weebles in Nigeria. My current pet project is developing strategies for how to break someone's ...
Repgradyjvierra, Animator at Alliance Global Servies
Je suis Grady de Phoenix USA. Je travaille en tant que technicien de laboratoire clinique dans la société Samuels Men ...
Repellaiyer15, Content Writer at Precious Moments
Committed to producing exceptional and creative types of content, including articles, internet content, advertisements, commercials, brochures, and publications. Experienced in ...
Repjacksssones433, Apple Phone Number available 24/7 for our Customers at A9
Proficient and creative WordPress developer with a strong history in website management and development. Experienced in SEO and PPC campaign ...
Repabbyherza, Animator at ASAPInfosystemsPvtLtd
I am Viola .I am A public relations consultant, a communications specialist who works as an intermediary between the public ...
Repkathyrnunez, Area Sales Manager at Advent
I am manager in a Star Bright Investment Group company. I like to solve puzzles for Has excellent problem-solving and ...
Rephazelwlson80, abc at A9
I am a skilled civil engineer with many years of experience in a variety of engineering aspects. There are a ...
Repshirleyjbarker439, Animator at ASAPInfosystemsPvtLtd
Hello, I am Gladys. I am a Industrial Photographer. I started off my photographic career as a News photographer based ...
Repthelmasaraht, Applications Developer at Accolite software
A child protection social worker is responsible for a variety of services designed to help families and children in a ...
RepI am Rasha , C/C++ certified Computer Programmer with expert-level competency in JavaScript, HTML and JSP and more than 6 ...
Repshawt146, Applications Developer at ADP
I love Exploring and photography. I want to fill my life with happiness and beautiful mammaries. I also like to ...
Repellenabeaudry4, Analyst at Boomerang Commerce
I'm a 23 year-old blogger, make-up junkie and follower of Hinduism.I love Reading because it brings happiness for ...
Repmartinskrull, Analyst at A9
Hi everyone, I am from new york,USA. I currently work in the Affiliate Marketing industry. I love all things ...
Repcolettehenna, OOPS Freshers at Bosch
I am Colette , policy analyst at Sunflower Market , with 3 years of experience building and maintaining relationships with elected officials ...
Reprealspellcaster4, Cloud Support Associate at Aricent
Hi, I am from PA, United states. I believe in making the impossible possible because there’s no fun in ...
RepSarahSKelly, Game Programmer at Akamai
I am Professor, and I am also a skilled fiction writer. I have a collection of novels published in the ...
RepHey, I am Margaret Salas, and I am working as a Web Developer Manager. And nowadays I am doing a ...
Rephelenweiver, Consultant at ASU
I am Helen , policy analyst at Sunflower Market , with 3 years of experience building and maintaining relationships with elected officials ...
Repannavhedge4, AT&T Customer service email at ABC TECH SUPPORT
Hi everyone, I am from Worcester,USA. I currently work in the Argus Tapes & Records as Scientific illustrator . I love ...
Repracheljennir, Personnel consultant at Infinite Wealth
Rachel, I am a Personnel consultant who acts as mediator between employers and job seekers. The main task of I ...
#include <bits/stdc++.h>
- manjuransari143 September 07, 2018using namespace std;
struct Node {
int data;
Node *left, *right;
};
Node* newNode(int data) {
Node *temp = new Node();
temp->data = data;
temp->left = NULL;
temp->right = NULL;
return temp;
}
int minTimeUtil(unordered_map<Node*, int> &minTime ,Node *root) {
if(root) {
minTimeUtil(minTime, root->left);
minTimeUtil(minTime, root->right);
if(root->left == NULL && root->right == NULL)
minTime[root] = 1;
else {
minTime[root] = min(root->left!=NULL?minTime[root->left]:INT_MAX, root->right!=NULL?minTime[root->right]:INT_MAX) + 1;
}
}
}
int main()
{
Node *root = newNode(1);
root->left = newNode(2);
root->right = newNode(3);
root->left->left = newNode(4);
root->left->right = newNode(5);
root->left->right->right = newNode(8);
root->left->left->left = newNode(6);
root->left->left->right = newNode(7);
unordered_map<Node*, int> minTime;
minTimeUtil(minTime, root);
int ans = 0;
for(auto n:minTime) {
cout<<n.first<<" "<<n.second<<endl;
ans = max(ans, n.second);
}
cout<<ans<<endl;
return 0;
}