Forgot Password ?
New password will be sent to following email id
Problem Code : UNIQUET
5 1 2 3 2 5 1 4 1 3 4 2 1 5
Time Limit :
C , C++ , Java , Python 2
Login to submit your response.
<p> Chotu and Motu are visiting a jungle </p> <p> They come across a magical tree, which has <b>N</b> nodes. <b>Each node i has value Arr [ i ].</b> </p> <p> The tree can fulfill any of their wishes, but for that they both need to solve a riddle.</p> <p> They need to find out <b>the number of magical nodes</b> in the tree. </p> <p> A Magical node <b>X</b> is a node if in <b>the path from root node 1 to node X (inclusive of both), all values are unique.</b> </p> <p> Help both of them. </p> <p><b>Source: Goldman Sachs Mid Internship Test 2017</b></p>
<p> First line comprises <b>N</b>- the number of nodes in the tree. </p> <p> Second line comprises N space separated integers Arr[ i ] denoting value of node i </p> <p><b>N-1</b> lines follow, each comprising 2 space separated integers - <b>a</b> and <b>b</b>, denoting an edge b/w these 2 nodes. </p>
<p>Print total number of magical nodes in the tree.</p>
<p><b>1<=N<=50000</b></p> <p><b>1<=Arr[ i ]<=10<sup>9</sup></b></p> <p><b>1<=a,b<=N</b></p>