12376 - As Long as I Learn, I Live


Difficulty : easy

Solution Description :

Graph BFS or DFS problem

This problem you can solve using recursive method, or you can use BFS or DFS for solve this problem.

The recursive method is best solution for solve this problem.

This method is

store all learning unit to LU[100]
total_learning_unit=LU[0];
run findAns(0);

void findAns(int u)
----if u has no adjacency node then set ans_node=u and return //i.e. break find ans
----find the max learning unit from all node which are adjacency of u. suppose the max learning unit node is v.
----total_learning_unit += LU[v];
----findAns(v);

print total_learning_unit and ans_node