Marks :10
: 1 | : 0
It is Rob's birthday and he is very excited about the night's birthday party. The city in which Rob lives has N blocks. The roads of this city are made in such a way that there is only one route from one city to another. Rob only has friends from all the dead ends of the city.
It is evening and Rob only wants to call the friends who live nearest to his house. Nearest houses are those which are at the same distance from Rob's house as the nearest dead end.
Rob lives in block 0. Help him find out the number of friends he can call for the birthday party.
The first line of input consists of a single integer $$$N$$$ $$$(1 \leq N \leq 10^6)$$$ - the total number of blocks in the city. Each of the next $$$N-1$$$ lines consists of two integers, $$$a_i$$$ and $$$b_i$$$, $$$(0 \leq a_i, b_i \leq N-1)$$$ denoting that there is a road between blocks $$$a_i$$$ and $$$b_i$$$.
The output should consist of a single integer, the total number of blocks in the city from which Rob can call friends.
5 0 1 1 2 1 3 1 4
3
5 0 1 1 2 1 3 3 4
1
You need to login to view your submissions.
You need to login to view all submissions.
Result : Executed
Feel something is wrong with the test cases?
Result : Accepted
Test Cases :
But to Run or Submit the Problem, you need to Log In.
Continue to Log InYour challenge has been submitted successfully.
You will get a response soon via WhatsApp or Email.
Do let us know your issue.