this discussion is related to problem Chipped Tree

As we know this problem is simply based on DFS traversing. During the contest i used following code for finding the depth of each node.

here

```
arr[MAX] // depth of nodes
int DFS(int u){
arr[u] = 1;
for(auto x : v[u])
arr[u] = max(arr[u], DFS(x)+1);
return arr[u];
}
```

and

edges inserted as following manner

```
int x, y; cin>>x>>y;
v[x].push_back(y).
```

but this code is givind WA. I do not know why?

VS CODE

and on the other most of the programmer use following code for finding Depth.

```
int DFS(int u, int par = 0){
arr[u] = 1;
for(auto x : v[u])
if(x != par)
arr[u] = max(arr[u], DFS(x, u)+1);
return arr[u];
}
```

and edges inserted in following way

```
int x, y; cin>>x>>y;
v[x].push_back(y);
v[y].push_back(x);
```

why?