Maximum difference between node and its ancestor in a Directed Acyclic Graph ( DAG )

#include
using namespace std;
  

void DFS(int src, vector Adj[],
         int& ans, int arr[],
         int currentMin, int currentMax)
{
  
    
    ans = max(
        ans, max(abs(
                     currentMax – arr[src – 1]),
                 abs(currentMin – arr[src – 1])));
  
    
    currentMin = min(currentMin,
                     arr[src – 1]);
  
    currentMax = min(currentMax,
                     arr[src – 1]);
  
    
    
    for (auto& child : Adj[src]) {
  
        
        
        DFS(child, Adj, ans, arr,
            currentMin, currentMax);
    }
}
  

void getMaximumDifference(int Edges[][2],
                          int arr[], int N,
                          int M)
{
  
    
    vector Adj[N + 1];
  
    
    for (int i = 0; i < M; i++) {         int u = Edges[i][0];         int v = Edges[i][1];                     Adj[u].push_back(v);     }        int ans = 0;             DFS(1, Adj, ans, arr,         arr[0], arr[0]);                  cout