You are given a list of integer lists vecs. Each element of vecs is a vector, and all vectors have the same number of entries. The squared length of a vector is the sum of the squares of its entries.
You may choose any subset of the vectors in vecs, including the empty subset, and add the chosen vectors entry by entry to form a new vector.
Return the largest possible squared length of that new vector.
Examples
Example 1
Input: vecs = [[3, 4]]
Output: 25
Explanation: The only vector is `[3, 4]`, whose squared length is 25.
Example 2
Input: vecs = [[1, 0],
[0, 1],
[1, 1]]
Output: 8
Explanation: Choosing all three vectors gives `[2, 2]`, whose squared length is `4 + 4 = 8`.
Example 3
Input: vecs = [[0, 0],
[0, 0]]
Output: 0
Explanation: Every subset sums to `[0, 0]`, so the largest squared length is 0.
Constraints
1≤vecs.length≤10
2≤vecs[0].length≤10
All elements of vecs have the same length.
−1000≤vecs[i][j]≤1000
Loading editor...
Log in to run your code. Your draft is saved in this browser.Log inSign up