Calculating the dp array for each possible position and calculating the max length that ends at a particular index
for a , b in v : NEW_LINE INDENT dp [ b [ 1 ] ] = max ( dp [ b [ 1 ] ] , 1 + dp [ b [ 0 ] ] ) NEW_LINE DEDENT ans = 1 NEW_LINE