I was trying to solve the problem using stack based dfs and i thought that if we calculate the max wealth value for each node i.e. maximum value of wealth among its superior nodes and itself then assign it .

then further find max difference value by subtracting the waelth value of each node with its maximum wealth value.

BUT i don't know were i went wrong can anyone point out my mistake here's my code:

#include <iostream>#include <algorithm>#include <list>#include <stack>using namespace std;long long int *mx;class graph{public:long long int v;list <long long int> *adj;public:

Read more… (76 words)