Given a binary tree/graph where each node have binary data 1 or 0.
Data for the nodes will be given in array where index represents node number and value represents data in the node.
Graph data is corrupter hence our problem to fix that corrupted data and also we are given corrected data in array.
Our task is to find the min steps required to fix the corrupted data.
Each step, we can do
Our task is to find min step required to fix.
public int minSteps(List adjList[], int n, int data[], int correctedData[]){
// write code here
}
Sample input
n = 5
Edges - (u, v)
1 2
2 3
2 4
1 5
data :[0 , 1, 0,1 ,0]
corrected data : [0, 0, 1 , 0, 0]

Answer = 1 step
inverting subtree of node 2