Problem Statement | |||||||||||||
The digit in element i character j of mat will correspond to the value in row i column j of an N x N matrix. Choosing k rows and k columns determines a k x k submatrix of mat. To compute the trace of such a submatrix S, first extract S from mat and reindex the rows and columns maintaining the original order. Add together all values along the main diagonal of the reindexed matrix (values with the same reindexed row and column). Return the largest trace considering all possible k x k submatrices. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | mat will contain between 1 and 50 elements, inclusive. | ||||||||||||
- | Each element of mat will contain exactly N digits ('0'-'9'), where N is the number of elements in mat. | ||||||||||||
- | k will be between 1 and N, inclusive, where N is the number of elements in mat. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
|