Company: Teradata

Difficulty: medium

Problem Statement

Division nodes Problem Description You are given a tree with N nodes connected by N - 1 edges, and each node carries a value listed in an array A. Write a program that picks an edge f to cut the tree along, so that the two resulting pieces have node-value sums as close to each other as possible. Function description Complete the solve function. This function takes the following 3 parameters and returns the answer. Parameters: N : Represents the count of a number of nodes edges : Represents the edges between nodes A : Represents the value associated with each node Input format for custom testing Note: Use this input format if you are testing against custom input or writing code in a language where we don't provide boilerplate code. The first line contains T denoting the number of test cases. For each test case: The second line contains N . Next N - 1 lines two space-separated integers U_i and V_i denoting that the edge number i connects the nodes U_i and V_i . The next line N space-sepa

More Teradata OA questionsInterview experiences