in the problem sugarel and love , how to choose two sons such that we can maximize
DP[i][1]={max(DP[j][0]+v[i][j]+DP[t][0]+v[i][t])∣ where j and t are sons of i}. For all other sons, we add max(DP[j][0],DP[j][1],DP[j][2]) as given in editorial
since there can be nC2 choices time complexity would be O(n2) , how to do it in O(n) time .
i think we can choose first two sums which gives max(DP[j][0]+v[i][j]+DP[t][0]+v[i][t]) as it will not always optimal .
any idea.